Skip to content

fix(error): prevent cleanup error from masking original error#214

Merged
DorianZheng merged 1 commit intomainfrom
fix/error-message-masking
Feb 6, 2026
Merged

fix(error): prevent cleanup error from masking original error#214
DorianZheng merged 1 commit intomainfrom
fix/error-message-masking

Conversation

@DorianZheng
Copy link
Copy Markdown
Member

Summary

  • Fix error masking when box initialization fails (e.g., image pull failure)
  • Remove redundant "Box not found:" prefix from NotFound error messages

Problem

When using a non-existent image, users saw:

box not found: Box not found: 01KGSJN01NWS16RJATH7C2N2Q7

Instead of the actual error:

storage error: Failed to pull image 'xxx' after trying 1 registry

Root cause: When start() fails during image pull, CleanupGuard::drop() removes the box from DB. Then stop() in the finally block tries to save to a deleted box, and that NotFound error overwrites the original error.

Changes

File Change
box_impl.rs Handle NotFound in stop() gracefully - if box already removed, return Ok(())
boxes.rs, rt_impl.rs, manager.rs, ffi.rs Remove redundant "Box not found:" prefix

Test plan

  • cargo check passes
  • Tested with non-existent image - now shows proper error message

When box initialization fails (e.g., image pull failure), the cleanup
guard removes the box from DB. If stop() is then called (e.g., from a
finally block), it would try to save to a non-existent box, returning
NotFound which masked the original error.

Changes:
- box_impl.rs: Handle NotFound gracefully in stop() - if box was already
  removed by cleanup, return Ok(()) instead of propagating the error
- Remove redundant "Box not found:" prefix from NotFound error messages
  since #[error("box not found: {0}")] already adds this prefix

Before: "box not found: Box not found: abc123"
After:  "box not found: abc123"

And most importantly, users now see the actual error:
"storage error: Failed to pull image 'xxx' after trying 1 registry"
instead of the misleading "box not found" error.
@DorianZheng DorianZheng merged commit b422926 into main Feb 6, 2026
13 checks passed
@DorianZheng DorianZheng deleted the fix/error-message-masking branch February 6, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant