Conversation
c05c7b9 to
a394dad
Compare
|
@swartzn Squash commits before merging if needed |
a394dad to
c48250b
Compare
| } | ||
|
|
||
| if !IsFileLocked(lockedInfo) { | ||
| if lockedInfo, writeLockSet, _, err = GetLockedInfo(ctx, r.mountPoint, mappings, cfg, cfg.Path); err != nil { |
Check warning
Code scanning / CodeQL
Impossible interface nil check Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the issue, change the assignment on line 374 from direct assignment to the outer err variable (of type error interface) to a short variable declaration, capturing the returned error value as its concrete type. This allows the subsequent nil check (if err != nil) to work as intended. Only assign to the outer return variable err after the check and if necessary (as in the error-handling block).
- Specifically, replace:
with:if lockedInfo, writeLockSet, _, err = GetLockedInfo(...); err != nil {var getLockedErr error if lockedInfo, writeLockSet, _, getLockedErr := GetLockedInfo(...); getLockedErr != nil { err = fmt.Errorf(..., getLockedErr.Error()) return }
This avoids the interface nil problem entirely.
Only the region inside common/rst/blob.go at line 374 requires changing, introducing a new error variable for this block-scoped assignment.
| @@ -371,8 +371,9 @@ | ||
| } | ||
|
|
||
| if !IsFileLocked(lockedInfo) { | ||
| if lockedInfo, writeLockSet, _, err = GetLockedInfo(ctx, r.mountPoint, mappings, cfg, cfg.Path); err != nil { | ||
| err = fmt.Errorf("%w: %s", ErrJobFailedPrecondition, fmt.Sprintf("failed to acquire lock: %s", err.Error())) | ||
| var getLockedErr error | ||
| if lockedInfo, writeLockSet, _, getLockedErr := GetLockedInfo(ctx, r.mountPoint, mappings, cfg, cfg.Path); getLockedErr != nil { | ||
| err = fmt.Errorf("%w: %s", ErrJobFailedPrecondition, fmt.Sprintf("failed to acquire lock: %s", getLockedErr.Error())) | ||
| return | ||
| } | ||
| cfg.SetLockedInfo(lockedInfo) |
What does this PR do / why do we need it?
Required for all PRs.
I got a little carried away one day and these changes just seemed to work. When I found
LocalStackwhich is an AWS emulator, I was curious about Azure and foundAzurite. Since Azure is not S3-compliant so this required a couple modifications to protobuf.Note: Requires protobuf branch
swartzn/add-azure-supportAre there any specific topics we should discuss before merging?
Not required.
What are the next steps after this PR?
Not required.
Checklist before merging:
Required for all PRs.
When creating a PR these are items to keep in mind that cannot be checked by GitHub actions:
For more details refer to the Go coding standards and the pull request process.