fix: keep the wrapped cause in NotFound and PermissionDenied messages - #5
Open
basgys wants to merge 1 commit into
Open
fix: keep the wrapped cause in NotFound and PermissionDenied messages#5basgys wants to merge 1 commit into
basgys wants to merge 1 commit into
Conversation
MissingFailure.Error and PermissionFailure.Error returned a bare constant and discarded the error they wrap, so WithNotFound(err) rendered as "resource not found" no matter what err said. Route both through maybeWrap, as the other failure types already do. The singletons wrap nil, so their messages are unchanged.
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_9644d9e0-8de0-4f34-bfe5-6ecd74f34e8c) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A production outage in lakehouse-games took far longer to diagnose than it should have, because the only thing the logs said was
pipeline: resource not found. The cause was a connector instance missing from the deployed config, and the error that knew its name —connector "wikipedia" not registered— was wrapped in aMissingFailureand thrown away.Why the cause disappeared
MissingFailure.ErrorandPermissionFailure.Errorreturned a bare constant and ignored the error they wrap, soWithNotFound(err)rendered asresource not foundregardless of whaterrsaid. Every other failure type in the package already routes throughmaybeWrapand appends the cause, which is what makesWithBadread asbad request: underlying issue. These two were the exceptions, and they are the two that most often carry the only useful detail — which resource, whose permission.Both now use
maybeWrap. TheNotFoundandPermissionDeniedsingletons wrap a nil error, andmaybeWrapreturns the bare message in that case, so their output does not change and neither does anything matching on it.The cause was always reachable through
Unwrap, so this changes only what callers see when they print or log the error — which is where it mattered.pkg/httpfaultsin lakehouse-games maps these to status codes by type, not by message, so response codes are unaffected; a handler that echoeserr.Error()into a response body will now include the wrapped cause, which is worth a look if any of them do that on a not-found path.Note
Low Risk
Localized error-string formatting in the faults package; type-based status mapping is unaffected, though any code that echoes
err.Error()on not-found paths may now expose more detail in responses.Overview
NotFound and PermissionDenied errors now surface wrapped causes in
Error()strings, matching how other fault types usemaybeWrap.MissingFailure.ErrorandPermissionFailure.Errorpreviously returned fixed"resource not found"and"permission denied"and dropped any parent passed throughWithNotFound/WithPermissionDenied, so logs often showed only the generic label. Both methods now callmaybeWrap, so wrapped errors read likeresource not found: underlying issue. Singletons with no wrapped error still return the same bare messages.Tests in
faults_test.goassert the new message format forWithNotFoundandWithPermissionDeniedwhen a cause is present.Unwrapanderrors.Isbehavior are unchanged; only printed/logged text changes for wrapped errors.Reviewed by Cursor Bugbot for commit 4f6549f. Bugbot is set up for automated code reviews on this repo. Configure here.