Fix AI calls failing in Docker with empty OPENAI_BASE_URL
docker compose passes an empty .env line as OPENAI_BASE_URL="", and with base_url=None the openai SDK fell back to that empty value, so every call failed with "Connection error". Always pass the base URL explicitly. Also disable gunicorn's unused control socket, which logged a permission error because /app is read-only for the app user. Found while deploying to the homelab server. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
dfa4813a42
commit
015a0a5821
@@ -392,3 +392,13 @@ def test_end_to_end_photo_import_through_sdk(stub_openai_server, user_client):
|
||||
assert response.context["form"].initial["title"] == "Linsen-Dal"
|
||||
parts = received["body"]["messages"][1]["content"]
|
||||
assert any(p["type"] == "image_url" and p["image_url"]["url"].startswith("data:image/jpeg;base64,") for p in parts)
|
||||
|
||||
|
||||
def test_empty_base_url_env_falls_back_to_openai(monkeypatch, settings):
|
||||
"""docker compose sets OPENAI_BASE_URL="" for an empty .env line; the SDK must not pick that up."""
|
||||
monkeypatch.setenv("OPENAI_BASE_URL", "")
|
||||
settings.OPENAI_API_KEY = "sk-test"
|
||||
settings.OPENAI_BASE_URL = ""
|
||||
assert str(ai._client().base_url).rstrip("/") == "https://api.openai.com/v1"
|
||||
settings.OPENAI_BASE_URL = "http://proxy.example/v1"
|
||||
assert str(ai._client().base_url).rstrip("/") == "http://proxy.example/v1"
|
||||
|
||||
Reference in New Issue
Block a user