Skip to content

fix: reject invalid REST path params with descriptive validation errors - #202

Merged
SeqviriouM merged 2 commits into
mainfrom
seqvirioum/invalid-path-params
Sep 15, 2026
Merged

SeqviriouM merged 2 commits into
mainfrom
seqvirioum/invalid-path-params

Conversation

@SeqviriouM

@SeqviriouM SeqviriouM commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Invalid REST path parameters now return a 400 INVALID_PARAMS error instead of inserting GATEWAY_INVALID_PARAM_VALUE into the URL. The error identifies the first invalid parameter by its full path, and the upstream request is not sent.

Partial related issue #14

Summary by Sourcery

Reject invalid REST path parameters before request dispatch and return descriptive validation errors identifying the offending argument.

Bug Fixes:

  • Reject invalid REST path parameters with a descriptive 400 INVALID_PARAMS validation error instead of inserting an invalid placeholder into the URL.
  • Prevent upstream requests when path parameter validation fails and report the first invalid parameter using its full argument path.

Enhancements:

  • Preserve existing schema-validation and unrelated path-function errors while supporting custom validation schemas.

Documentation:

  • Document the new INVALID_PARAMS response details and upstream request behavior for invalid REST path parameters.

Tests:

  • Add coverage for invalid nested, array, encoded, and unpaired Unicode path parameters, request suppression, custom schemas, and preserved errors.

@sourcery-ai

sourcery-ai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Reviewer's Guide

REST path parameters are now validated during path construction and invalid values fail fast with a descriptive 400 INVALID_PARAMS error containing the first invalid parameter’s full path; no upstream request is sent, while schema validation and unrelated path errors retain their existing behavior.

File-Level Changes

Change Details Files
Reject invalid path parameters at the point where REST action paths are built, instead of substituting a sentinel URL value.
  • Added recursive path tracking for nested objects and arrays.
  • Changed invalid values and URI-encoding failures to invoke a configurable invalid-parameter callback.
  • Preserved opt-out behavior when path validation is disabled.
lib/utils/validate.ts
lib/utils/validate.test.ts
Return a structured 400 validation error and prevent upstream requests when path validation fails.
  • Centralized error construction with status 400, code INVALID_PARAMS, and an Invalid path params title.
  • Identified the first invalid parameter using its full argument path.
  • Ended the context before propagating the rejected error, while preserving existing schema-validation behavior and unrelated path-function errors.
lib/components/rest.ts
lib/index.test.ts
Document the new REST path-parameter validation contract.
  • Replaced the sentinel error behavior with the INVALID_PARAMS response contract.
  • Documented the error title, parameter-path description, and upstream request prevention.
README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread lib/utils/validate.ts
@SeqviriouM
SeqviriouM merged commit 8a1de89 into main Sep 15, 2026
9 checks passed
@SeqviriouM
SeqviriouM deleted the seqvirioum/invalid-path-params branch September 15, 2026 08:30
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.

2 participants