Type query parameters and reject requests with a missing id#14778
Open
iliaal wants to merge 1 commit into
Open
Type query parameters and reject requests with a missing id#14778iliaal wants to merge 1 commit into
iliaal wants to merge 1 commit into
Conversation
queryStringParameters was typed as any and read as request.queryStringParameters.id directly. API Gateway sends null when there is no query string, so retrieveResult, retrieveSample and retrieveLegacyResult threw a TypeError that surfaced as an opaque 500. Type the field, add a requireId() guard that returns 400 when id is absent, and replace the deprecated id.substr with id.slice. Broader request-body typing is left for a follow-up.
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.
Before:
queryStringParametersis typedanyand read asrequest.queryStringParameters.id. API Gateway sendsnullwhen there's no query string, soretrieveResult,retrieveSampleandretrieveLegacyResultthrow aTypeErrorthat surfaces as an opaque 500.After: the field is typed, a
requireId()guard returns 400 whenidis absent, and the deprecatedid.substrbecomesid.slice.Scope: broader request-body typing left for a follow-up.
tsc --noEmitis clean. eslint can't run in a fresh checkout because of a pre-existinges2024lib/parser mismatch that also fails on the unmodified baseline.Overlaps the dedup PR (branch
refactor/playground-api-dedup) inhandler.ts; rebase whichever merges second.