Skip to content

Log expected route-handler not-found at debug instead of error#1771

Open
muk2 wants to merge 1 commit into
apple:mainfrom
muk2:fix/589-snapshotget-error-message
Open

Log expected route-handler not-found at debug instead of error#1771
muk2 wants to merge 1 commit into
apple:mainfrom
muk2:fix/589-snapshotget-error-message

Conversation

@muk2

@muk2 muk2 commented Jun 20, 2026

Copy link
Copy Markdown

Summary

Logs an expected notFound result from an XPC route handler at debug instead
of error. Looking up a resource that does not yet exist (for example, a
snapshot before it has been unpacked) is a normal, recoverable outcome, but it
was being logged as handler for snapshotGet threw error notFound, which is
misleading. The error is still returned to the client unchanged; only the
server-side log level is lowered. All other error codes continue to log at
error.

Testing

  • make check passes (formatting + license headers).
  • Unit tests: new RouteHandlerLogLevelTests (2 tests, in a new ContainerXPCTests
    target) assert notFound maps to debug and other codes map to error. All pass.

Fixes #589

A snapshotGet (and any other route) that returns a `notFound`
ContainerizationError is an expected, recoverable outcome: the client
catches it and unpacks the image. Logging it via the generic XPC route
dispatcher at `error` level produced a misleading log line such as
`handler for snapshotGet threw error notFound: "image snapshot for ref"`.

Downgrade `notFound` results to `debug` in the route handler error path
while still replying with the error so clients can act on it. The
decision is factored into `ContainerizationError.routeHandlerLogLevel`
so it can be unit tested on platforms that cannot build the macOS-only
XPC server.

Fixes apple#589
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.

[Bug]: Error log message is misleading: handler for snapshotGet threw error notFound: "image snapshot for ref"

1 participant