mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
[GH-ISSUE #20938] issue: Uncaught ValueError in APIKeyRestrictionMiddleware causes HTTP 500 on malformed Authorization header #34863
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ThanosTsiamis on GitHub (Jan 26, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/20938
Check Existing Issues
Installation Method
Git Clone
Open WebUI Version
v0.7.2
Ollama Version (if applicable)
No response
Operating System
macOS Tahoe
Browser (if applicable)
No response
Confirmation
README.md.Expected Behavior
The server should handle malformed Authorization headers gracefully. If a client sends a header with irregular spacing (e.g., double spaces) or missing components, the server should catch the parsing error and return a 401 Unauthorized or 400 Bad Request response, rather than crashing the request handler.
Actual Behavior
When a malformed Authorization header is received (specifically one that causes split(" ") to return more or fewer than 2 items), the application raises an uncaught ValueError. This causes the Uvicorn worker to crash on that specific request and return a 500 Internal Server Error to the client.
Steps to Reproduce
Deploy Open WebUI (verified on version 0.7.2) using Docker or pip install.
Start the server (e.g., open-webui serve).
Open a terminal and send a request with a malformed Authorization header. Note the double space between "Bearer" and the token string in the command below:
Observe the HTTP response status code is 500 Internal Server Error.
Check the server console logs to see the Python traceback.
Logs & Screenshots
Additional Information
No response
@ThanosTsiamis commented on GitHub (Jan 26, 2026):
I have implemented a fix for this issue in my fork by adding error handling to the header parsing logic. If this approach looks correct to the maintainers, I am ready to submit a Pull Request.
Fix Branch: https://github.com/ThanosTsiamis/open-webui/tree/fix/middleware-auth-header-crash
@tjbck commented on GitHub (Feb 6, 2026):
Addressed in dev.