feat(gateway): add input validation to LandController#42
Merged
Conversation
sbalabanov
requested changes
Feb 23, 2026
|
|
||
| // Validate required fields. | ||
| if req.Queue == "" { | ||
| return nil, fmt.Errorf("queue name is required") |
Contributor
There was a problem hiding this comment.
may I suggest some specific wording to help better identify where the error came from
i.e. LandController requires the request to have a queue name specified
Contributor
There was a problem hiding this comment.
You also likely want a specific error type to signal back to the server that the error is user error, so it could emit an appropriate GRPC code and metadata
| _, err := controller.Land(ctx, req) | ||
|
|
||
| require.Error(t, err) | ||
| assert.Contains(t, err.Error(), "at least one change ID is required") |
Contributor
There was a problem hiding this comment.
Plz do not assert on eroor message
CLAUDE.md has a specific instruction on this one
Add input validation for LandRequest before processing: - Validate queue name is not empty - Validate change source is not empty (handles nil change) - Validate at least one change ID is provided Introduce ErrInvalidRequest sentinel error following the existing pattern from extension/storage. This allows the gRPC layer to map validation errors to codes.InvalidArgument. Tests verify error type using IsInvalidRequest() helper, following CLAUDE.md guidance to avoid asserting on error messages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
e5c450b to
68e2402
Compare
sbalabanov
approved these changes
Feb 23, 2026
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?
Validate required fields before processing land requests:
Why?
The LandController.Land() method currently accepts requests without validating required fields.
Failures occur deep in the processing pipeline instead of at the entry point with clear messages
Test Plan
TestLand_ReturnsErrorOnEmptyQueueTestLand_ReturnsErrorOnEmptyChangeSourceTestLand_ReturnsErrorOnNilChangeTestLand_ReturnsErrorOnEmptyChangeIDsIssue
N/A