Fixing ListBatches REST path filter silently returns empty on wrong batch_key encoding#2137
Fixing ListBatches REST path filter silently returns empty on wrong batch_key encoding#2137sergey3bv wants to merge 2 commits into
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where the ListBatches REST endpoint would silently return empty results when provided with incorrectly encoded batch keys. By migrating the path parameter to a string-based representation and introducing strict validation logic, the API now provides clear feedback when invalid inputs are received, improving robustness and developer experience. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
46aaa41 to
4ad88ea
Compare
There was a problem hiding this comment.
Code Review
This pull request updates the ListBatches REST endpoint to use batch_key_str in the path and ensures that malformed or empty batch keys return an InvalidArgument error. It also adds an integration test to verify correct handling of various batch key encodings. Feedback focuses on adhering to the repository style guide, specifically regarding the placement of comments within switch statements and the minimization of lines for error message formatting in rpcserver.go.
4ad88ea to
81c1f7d
Compare
| // parallel tranches, tapd block processing can be slow so we use a | ||
| // generous timeout. | ||
| ccTransferTimeout = 2 * time.Minute | ||
| ccTransferTimeout = 3 * time.Minute |
There was a problem hiding this comment.
Please remove from PR.
| ctxt, cancel := context.WithTimeout( | ||
| ctxb, defaultWaitTimeout*4, | ||
| ) |
There was a problem hiding this comment.
Please remove from PR.
| "invalid batch_key: %v", err) | ||
| } | ||
|
|
||
| default: |
There was a problem hiding this comment.
either no default here or a generic unsupported filter type with a // should be unreachable comment.
| batchKey, | ||
| ), | ||
| statusCode: []int{ | ||
| http.StatusBadRequest, http.StatusNotFound, |
There was a problem hiding this comment.
why accept multiple status codes here?
| } | ||
|
|
||
| for _, testCase := range testCases { | ||
| testCase := testCase |
There was a problem hiding this comment.
not needed in modern Go 1.22+
| return nil, fmt.Errorf("invalid batch key string: %w", | ||
| err) | ||
| return nil, status.Errorf(codes.InvalidArgument, | ||
| "invalid batch_key: %v", err) |
There was a problem hiding this comment.
old error messages seemed alright. Here you are pretending to now what the field name is (happens to also be wrong since it's batch_key_str).
| if err != nil { | ||
| return nil, fmt.Errorf("invalid batch key: %w", err) | ||
| return nil, status.Errorf(codes.InvalidArgument, | ||
| "invalid batch_key: %v", err) |
There was a problem hiding this comment.
old error messages seemed alright. Here you are pretending to now what the field name is (happens to also be wrong since it's batch_key_str).
| if err != nil { | ||
| return nil, fmt.Errorf("invalid batch key: %w", err) | ||
| return nil, status.Errorf(codes.InvalidArgument, | ||
| "invalid batch_key: %v", err) |
There was a problem hiding this comment.
old error messages seemed alright. Here you are pretending to now what the field name is.
Should close #2080