Skip to content

Validate typed parameters before each request encoding - #4

Merged
kdubb merged 2 commits into
mainfrom
codex/typed-request-parameters
Oct 2, 2026
Merged

kdubb merged 2 commits into
mainfrom
codex/typed-request-parameters

Conversation

@kdubb

@kdubb kdubb commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Typed request parameters currently bypass request-mode validation, especially on bodyless operations. Add an optional parameter-validation callback that runs before each request encoding and rechecks mutable values on repeated/deferred executions. Generated callbacks reuse native model validation.

Litestar whole-query models now use request-mode Pydantic validation and translate failures to HTTP 400.

Ordinary and SSE request builds share RequestEncodingError translation. Litestar returns structured errors without submitted inputs or non-serializable context objects.

Validation: Ruff, mypy src tests tools, and all 208 tests passed; coverage is 91.89%. The Litestar regression verifies HTTP 400 before delegate invocation.

Companion fix for Sunday Generator PR #243. This runtime must be released before the generator emits the new hook.

Invoke a typed-parameter validation callback before each request encoding, including bodyless and deferred operations. Document custom transport responsibilities and cover mutation after a successful request build. Validate Litestar whole-query models in request mode and translate failures to HTTP 400 before delegate invocation.
@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Adds parameter validation before request encoding.

The PR appears safe to merge; no new actionable issue or outstanding previous finding was identified.

Summary

The PR adds per-encoding validation for typed request parameters, routes ordinary and SSE requests through shared encoding-error translation, and returns structured HTTP 400 responses for invalid Litestar query models. The three previous findings are fixed in the current code.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Ordinary or SSE request] --> B[Build request]
  B --> C[Validate parameters and body]
  C --> D[Encode request]
  C -->|Validation failure| E[RequestEncodingError]
  D -->|Encoding failure| E
Loading

Reviews (2) · Last reviewed commit: "Unify streaming parameter errors and str..."

Comment thread src/sunday/httpx/_transport.py
Comment thread src/sunday/litestar.py Outdated
Comment thread tests/test_codecs_operations.py
Translate encoding failures at the shared request build boundary for ordinary and SSE requests. Return structured Litestar validation diagnostics without submitted inputs or non-serializable contexts. Cover encoded query values, terminal SSE failures, and safe server error responses.
@kdubb
kdubb merged commit affa809 into main Oct 2, 2026
6 checks passed
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