tiangolo/fastapi · error · HTTPException
No Jessica token provided
Error message
No Jessica token provided
What it means
Raised by the get_query_token dependency when the query parameter named token is not equal to "jessica", returning HTTP 400. Unlike the header checks, this validates a URL query parameter, demonstrating FastAPI's ability to gate the app/router on a query value.
Source
Thrown at docs_src/bigger_applications/app_an_py310/dependencies.py:13
from typing import Annotated
from fastapi import Header, HTTPException
async def get_token_header(x_token: Annotated[str, Header()]):
if x_token != "fake-super-secret-token":
raise HTTPException(status_code=400, detail="X-Token header invalid")
async def get_query_token(token: str):
if token != "jessica":
raise HTTPException(status_code=400, detail="No Jessica token provided")
View on GitHub (pinned to 42a41db11f)
Solutions
- Append ?token=jessica to the request URL.
- When using TestClient, pass params={"token": "jessica"}.
- Confirm the param name and value against the dependency definition.
Example fix
# before
client.get("/")
# after
client.get("/", params={"token": "jessica"}) Defensive patterns
Strategy: validation
Validate before calling
# Ensure the token query param is set
params = {"token": "jessica"}
client.get("/", params=params) Type guard
def has_query_token(params: dict) -> bool:
return params.get("token") == "jessica" Prevention
- Append ?token=jessica to every URL.
- Use params= in TestClient rather than string concatenation.
- Confirm query params survive any proxy/redirect.
When it happens
Trigger: A request whose URL lacks ?token=jessica, e.g. GET / without the query param, or GET /?token=wrong.
Common situations: Clients building URLs without the token query param; query stripped by a proxy/redirect; assuming auth is header-only.
Related errors
- X-Token header invalid
- X-Token header invalid
- X-Key header invalid
- X-Token header invalid
- X-Key header invalid
AI-assisted analysis of tiangolo/fastapi@42a41db11f (2026-08-04).
Data as JSON: /data/errors/1365ee70a9f6ea2e.json.
Report an issue: GitHub.