Skip to content

Type query parameters and reject requests with a missing id#14778

Open
iliaal wants to merge 1 commit into
phpstan:2.2.xfrom
iliaal:refactor/playground-api-request-typing
Open

Type query parameters and reject requests with a missing id#14778
iliaal wants to merge 1 commit into
phpstan:2.2.xfrom
iliaal:refactor/playground-api-request-typing

Conversation

@iliaal
Copy link
Copy Markdown

@iliaal iliaal commented Jun 5, 2026

Before: queryStringParameters is typed any and read as request.queryStringParameters.id. API Gateway sends null when there's no query string, so retrieveResult, retrieveSample and retrieveLegacyResult throw a TypeError that surfaces as an opaque 500.
After: the field is typed, a requireId() guard returns 400 when id is absent, and the deprecated id.substr becomes id.slice.

Scope: broader request-body typing left for a follow-up. tsc --noEmit is clean. eslint can't run in a fresh checkout because of a pre-existing es2024 lib/parser mismatch that also fails on the unmodified baseline.

Overlaps the dedup PR (branch refactor/playground-api-dedup) in handler.ts; rebase whichever merges second.

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.
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.

1 participant