Fix: address multiple minor bugs found during code audit#492
Fix: address multiple minor bugs found during code audit#492vinayakjeet wants to merge 1 commit intourunc-dev:mainfrom
Conversation
- Use annotHypervisor instead of annotType in isRunning() - Remove nil error wrapping in run.go - Fix potential nil-deref on consoleFile in rootfs.go - Use errors.Is() for sentinel error comparison - Propagate errors in getInitPid instead of swallowing - Propagate error in deleteAllTCFilters Signed-off-by: vinayakjeet <vinayakjeetog@gmail.com>
✅ Deploy Preview for urunc ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
hi @cmainas can you please review the changes . |
IrvingMg
left a comment
There was a problem hiding this comment.
Some changes need to be reviewed, as they’re breaking unit tests and may not be actual bugs. You can run make unittest to verify that they pass.
| file, err := os.Open(filePath) | ||
| if err != nil { | ||
| return 0, nil | ||
| return 0, fmt.Errorf("failed to open %s: %w", filePath, err) |
There was a problem hiding this comment.
I’m not sure this is actually a bug. This change is breaking the test case "init PID file not found," which suggests that nil is the expected return value.
Could you please verify?
| if err := decoder.Decode(&jsonData); err != nil { | ||
| return 0, nil | ||
|
|
||
| return 0, fmt.Errorf("failed to decode JSON from %s: %w", filePath, err) |
There was a problem hiding this comment.
Same as above. This breaks test "init PID invalid JSON". Please verify.
| return err | ||
| } | ||
| return fmt.Errorf("urunc run failed: %w", nil) | ||
| return fmt.Errorf("urunc run is not supported") |
There was a problem hiding this comment.
Why are we returning "urunc run is not supported"?
I don't know why we’re always returning an error here, but it looks like it should be nil instead of an "unsupported" error. Could you please double-check?
Description
Refactor error handling and nil-safety: use annotHypervisor in isRunning, remove nil error wrapping, fix consoleFile nil-deref, use errors.Is for sentinel checks, and propagate errors from getInitPid and deleteAllTCFilters.
Related issues
None
How was this tested?
lint and build
LLM usage
None
Checklist
make lint).make test_ctr,make test_nerdctl,make test_docker,make test_crictl).