mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-08 21:09:41 -05:00
AttributeError: 'State' object has no attribute 'ENABLE_API_KEY_ENDPOINT_RESTRICTIONS' when accessing API via curl #3133
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 @ZipingL on GitHub (Dec 28, 2024).
Bug Report
Installation Method
I installed OpenWebUI using
pip installwithin a Python 3.11 virtual environment created with Miniconda.Environment
Open WebUI Version: [v0.3.11]
Ollama (if applicable): [N/A]
Operating System: Ubuntu 24.04
Browser (if applicable): N/A
Confirmation:
Expected Behavior:
When making an API request to
/api/modelswith a valid API key usingcurl, the application should validate the API key and return the appropriate response without errors. TheENABLE_API_KEY_ENDPOINT_RESTRICTIONSattribute should be properly recognized by the application.Actual Behavior:
When making an API request to
/api/modelswith a valid API key in the Authorization header usingcurl, the application fails and raises the following error:bash
This issue occurs because the
ENABLE_API_KEY_ENDPOINT_RESTRICTIONSattribute is not initialized in the application state (app.state). However, when accessing the same endpoint via a web browser, the error does not occur, and the endpoint functions as expected.Description
Bug Summary:
The application attempts to access
request.app.state.ENABLE_API_KEY_ENDPOINT_RESTRICTIONSduring API requests made usingcurl, but this attribute is not initialized, resulting in anAttributeError. This issue does not occur when accessing the same endpoint via a web browser, leading to inconsistent behavior.Reproduction Details
Steps to Reproduce:
/api/modelswith a valid API key in theAuthorizationheader usingcurl:Logs and Screenshots
Relevant Logs:
Screenshots/Screen Recordings (if applicable):
N/A
Additional Information
Suggested Fix:
The issue can be resolved by:
Using
getattrto handle the missing attribute gracefully inauth.py at line 99:Environment Details:
/api/models@tjbck commented on GitHub (Dec 28, 2024):
#8135
@ZipingL commented on GitHub (Dec 28, 2024):
Cool beans