tiangolo/fastapi · error · HTTPException
Item not found, there's only a plumbus here
Error message
Item not found, there's only a plumbus here
What it means
Non-Annotated variant of error 26: same 404 "Item not found, there's only a plumbus here" with the re-raising yield dependency. Fires for unknown item_ids other than "portal-gun".
Source
Thrown at docs_src/dependencies/tutorial008d_py310.py:25
pass
def get_username():
try:
yield "Rick"
except InternalError:
print("We don't swallow the internal error here, we raise again 😎")
raise
@app.get("/items/{item_id}")
def get_item(item_id: str, username: str = Depends(get_username)):
if item_id == "portal-gun":
raise InternalError(
f"The portal gun is too dangerous to be owned by {username}"
)
if item_id != "plumbus":
raise HTTPException(
status_code=404, detail="Item not found, there's only a plumbus here"
)
return item_id
View on GitHub (pinned to 42a41db11f)
Solutions
- Call /items/plumbus.
- Avoid /items/portal-gun in this variant (InternalError propagates as 500).
- Keep 404 detail consistent across Annotated/non-Annotated variants.
- Test all three id branches.
Example fix
# before
if item_id != "plumbus":
raise HTTPException(status_code=404, detail="Item not found, there's only a plumbus here")
# after
if item_id != "plumbus":
raise HTTPException(status_code=404, detail=f"Item '{item_id}' not found") Defensive patterns
Strategy: validation
Validate before calling
if item_id != "plumbus":
raise ValueError("only plumbus is safe") Type guard
def is_safe_item(item_id: str) -> bool:
return item_id == "plumbus" Try / catch
r = client.get(f"/items/{item_id}")
if r.status_code == 404:
...
elif r.status_code >= 500:
# re-raised InternalError (e.g. portal-gun)
... Prevention
- Avoid portal-gun on this variant.
- Validate id before sending.
- Handle 5xx distinctly from 404.
When it happens
Trigger: GET /items/<not-plumbus-and-not-portal-gun> in the tutorial008d_py310 endpoint.
Common situations: Unknown resource ids; clients expecting the swallowed-error behavior from 008c now seeing 500s on portal-gun because the dependency re-raises.
Related errors
- Item not found
- Item not found, there's only a plumbus here
- Item not found, there's only a plumbus here
- Item not found, there's only a plumbus here
- Item not found
AI-assisted analysis of tiangolo/fastapi@42a41db11f (2026-08-04).
Data as JSON: /data/errors/48a554ee92d6b27f.json.
Report an issue: GitHub.