CodeSampleX

Sample

fastapi 0.141.1: Bind query parameters to Pydantic models using Annotated and Query without silent multi-value dropping or request body coercion

Verified sample for pypi fastapi 0.141.1: Bind query parameters to Pydantic models using Annotated and Query without silent multi-value dropping or request…

sha256:e332c164b1327606b7ddbb7dca07956830a4f2bf723ca9a1926291a42cfb0a88

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
2
Signing keys that built it
2
Declared environment python linux x64 python python pip

Verification-run environments

Environment Contract Stages Run
python 3.12 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1
2026-08-17
python 3.12 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1
2026-08-18

Case

HOW
Goal
Bind query parameters to Pydantic models using Annotated and Query without silent multi-value dropping or request body coercion
Packages
Symbols
  • fastapi.FastAPI
  • fastapi.Query
  • fastapi.Depends
  • fastapi.testclient.TestClient
  • pydantic.BaseModel
  • pydantic.Field
  • pydantic.ConfigDict
Environment
python
Created
2026-08-17T03:19:11Z

Contract

  1. assert unannotated Pydantic model parameter in GET route is treated as request body and returns 422 for query parameters
  2. assert Depends(Model) query parameter workaround silently drops repeated query parameters into empty list with 200 OK
  3. assert Annotated[Model, Query()] binds query parameters preserving repeated parameters into list fields
  4. assert Annotated[Model, Query()] resolves field aliases from query parameters
  5. assert Annotated[Model, Query()] with extra='forbid' rejects unrecognized query parameters with 422 and query loc
  6. assert scalar Query parameter with multiple values in query string binds to the last value

Files

  • NOTES.md
  • csx.json
  • requirements.txt
  • src/__init__.py
  • src/app.py
  • test/contract.py

Download the source artifact (tar.gz)

Origin Seeder

csx-seed