feat(httpapi): expose request parse options in HttpApiBuilder - #8268
Closed
gold-beyond wants to merge 1 commit into
Closed
gold-beyond wants to merge 1 commit into
gold-beyond wants to merge 1 commit into
Conversation
Add `parseOptions` to `HandlerOptions` so request decoding can be
configured, for example to collect every decoding error with
`{ errors: "all" }` instead of only the first one.
The option is threaded through `HandlerRuntime` into
`handlerToHttpEffect` and applies to `params`, `headers`, `query`, and
`payload` decoding. `HttpApiBuilder.endpoint` accepts the same option.
Closes Effect-TS#8266
🦋 Changeset detectedLatest commit: b92f289 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
This branch is waiting to be deployed
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.
Closes #8266
Adds
parseOptionstoHttpApiBuilderhandler options, so the parse options used when decoding request parts can be configured. This makes it possible to collect every decoding error instead of only the first one.HandlerOptions.parseOptionsis threaded throughHandlerRuntimeintohandlerToHttpEffectand applies toparams,headers,query, andpayloaddecoding.HttpApiBuilder.endpointaccepts the same option, andhandleAllentries accept it through their existingoptionsfield.handleRawapplies it toparams,headers, andquerywhile leaving the payload to the handler.When the option is not supplied, decoding is unchanged: the decoders are built with
Schema.decodeUnknownEffect(schema)exactly as before, so the existing fast path and default behavior are preserved.Validation
src/unstable/httpapi/HttpApiBuilder.test.tscovering the payload path (default anderrors: "all"), the query path, thehandleRawpayload opt-out, andHttpApiBuilder.endpoint.decodeQuery, dropping the!isRawguard, or dropping the option insideHttpApiBuilder.endpointfails exactly the corresponding test and nothing else. Reverting the change entirely makes theerrors: "all"test fail while the default-behavior test stays green, which is what pins the opt-in semantics.vitest run packages/effect/test/unstable/httpapipasses (203 tests).pnpm lint-fix,pnpm lint, andpnpm checkpass.effect-jsdocs --checkreports no diagnostics forHttpApiBuilder.ts. Pre-existing diagnostics insrc/unstable/ai/McpSchema.tsare outside this PR.