Repository navigation
Conversation
An instant query with an invalid time parameter returned 500 server_error instead of 400 bad_data. util.ParseTimeParam wraps the 400 httpgrpc error with errors.Wrapf, and DecorateWithParamName used gogo/status.FromError, which doesn't unwrap errors, so the status was lost and the error was reported as a server error. Use google.golang.org/grpc/status, whose FromError finds the status of a wrapped error. The error message is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YDgKpXdZmLs9YSYU1ZSf8d Signed-off-by: Andrey Osipov <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YDgKpXdZmLs9YSYU1ZSf8d Signed-off-by: Andrey Osipov <[email protected]>
This branch has not been deployed
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.
What this PR does:
Returns
400 bad_datainstead of500 server_errorfor an instant query with an invalidtimeparameter, for example/api/v1/query?query=up&time=invalid.util.ParseTimeParamreturns the400httpgrpcerror fromutil.ParseTimewrapped witherrors.Wrapf.DecorateWithParamNamethen usedgogo/status.FromError, which only looks at the error itself and doesn't unwrap it, so the status was lost andRespondFromGRPCErrorreported it as a server error. This PR switchesDecorateWithParamNametogoogle.golang.org/grpc/status, whoseFromErrorfinds the status of a wrapped error. The error message is unchanged.The
start,endandstepparameters of range queries weren't affected, because their errors aren't wrapped.Test_InvalidParamReturnsBadRequestcovers them too, as a regression test. Thetimecase of that test and the wrapped error case ofTest_DecorateWithParamNamefail without the change.The message of a wrapped error still includes the gRPC status text, as it did before:
invalid parameter "time"; Invalid time value for 'time': rpc error: code = Code(400) desc = cannot parse "invalid" to a valid timestamp. Using the message of the innermost status would make it cleaner, but would change the error text users see, so I left it out. Happy to do it here or in a follow-up if you prefer.I noticed this while testing #7979.
Which issue(s) this PR fixes:
None, I found no existing issue.
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]docs/configuration/v1-guarantees.mdupdated if this PR introduces experimental flagsAI disclosure: per GENAI_POLICY.md, the fix and the tests were prepared with Claude Code. I reviewed and verified the changes.
🤖 Generated with Claude Code