python type_error ai_generated true

ValueError: 99 is not a valid HTTP status code

ID: python/starlette-http-exception-invalid-status

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2025-11-05First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

Passing an invalid status code to HTTPException or Response.

generic

中文

向 HTTPException 或 Response 传递了无效的状态码。

Workarounds

  1. 100% success
    Use a valid status code: raise HTTPException(status_code=404, detail='Not Found')
  2. 90% success
    Check the status code before using: if 100 <= code <= 599: use it else: raise ValueError

Dead Ends

Common approaches that don't work:

  1. 90% fail

    Status codes must be integers between 100 and 599.

  2. 80% fail

    600 is not a standard HTTP status code.