# Bug: `remove_file` in core-dump-agent called on non-existent file due to inverted logic
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Start at the core-dump-agent's remove function and inspect the existence check immediately before fs::remove_file. Correct the condition so existing files are removed while missing files do not cause an error. Verify cleanup behavior for both an existing crictl executable and a missing one using the repository's available checks.
Written by the indexing model from the issue text.
Description
Bug: remove_file in core-dump-agent called on non-existent file due to inverted logic
Description
In the remove function, there is a logic error in the file existence check preceding fs::remove_file:
if !Path::new(&crictl_exe).exists() {
fs::remove_file(crictl_exe)?;
}
The condition !Path::new(&crictl_exe).exists() evaluates to true when the file does not exist. Inside the if block, fs::remove_file(crictl_exe)? is then called, which attempts to delete a file that has just been confirmed as absent.
std::fs::remove_file on a non-existent path returns std::io::Error with ErrorKind::NotFound, which propagates up via the ? operator. This causes the function to fail in cases where the file is genuinely missing, potentially breaking cleanup or teardown workflows.
Expected behavior
- If the file exists → remove it.
- If the file does not exist → do nothing (or log a debug message), without returning an error.
Actual behavior
- If the file does not exist →
fs::remove_filereturnsErrorKind::NotFound, which is propagated via?, causing the function to fail.
Proposed fix
Option A — correct the logic:
if Path::new(&crictl_exe).exists() {
fs::remove_file(crictl_exe)?;
}
Severity
Medium — the function fails when the file is missing, which can break teardown/cleanup flows.
Labels
bug, cleanup, io
- Dominant language
- Rust
- Stars
- 160
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from IBM/core-dump-handler
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
IBM/core-dump-handler#188 · 1 reaction ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
IBM/core-dump-handler#185 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
IBM/core-dump-handler#179 · 4 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
IBM/core-dump-handler#178 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
IBM/core-dump-handler#173 · 3 comments · 1 reaction ·
All issues in IBM/core-dump-handler
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100