Skip to content

feat(gateway): add input validation to LandController#42

Merged
djuloori2794 merged 1 commit into
mainfrom
feat/gateway-input-validation
Feb 23, 2026
Merged

feat(gateway): add input validation to LandController#42
djuloori2794 merged 1 commit into
mainfrom
feat/gateway-input-validation

Conversation

@djuloori2794
Copy link
Copy Markdown
Contributor

What?

Validate required fields before processing land requests:

  • Queue name must not be empty
  • Change source must not be empty
  • At least one change ID must be provided

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

  • Added TestLand_ReturnsErrorOnEmptyQueue
  • Added TestLand_ReturnsErrorOnEmptyChangeSource
  • Added TestLand_ReturnsErrorOnNilChange
  • Added TestLand_ReturnsErrorOnEmptyChangeIDs
  • All existing tests pass

Issue

N/A

Comment thread gateway/controller/land.go Outdated

// Validate required fields.
if req.Queue == "" {
return nil, fmt.Errorf("queue name is required")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread gateway/controller/land_test.go Outdated
_, err := controller.Land(ctx, req)

require.Error(t, err)
assert.Contains(t, err.Error(), "at least one change ID is required")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@djuloori2794 djuloori2794 force-pushed the feat/gateway-input-validation branch from e5c450b to 68e2402 Compare February 23, 2026 20:52
@djuloori2794 djuloori2794 merged commit 09f7c72 into main Feb 23, 2026
1 check passed
@behinddwalls behinddwalls deleted the feat/gateway-input-validation branch June 2, 2026 18:39
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.

3 participants