[GH-ISSUE #187] run: OPEN_TERMINAL_API_KEY_FILE crashes startup (both _FILE and env var set) #110

Open
opened 2026-10-18 21:10:52 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @jamesdury on GitHub (Oct 7, 2026).
Original GitHub issue: https://github.com/open-webui/open-terminal/issues/187

open-terminal run cannot start when the key is given through OPEN_TERMINAL_API_KEY_FILE, the Docker-secrets route env.py documents.

Reproduce

echo secret > /tmp/key
OPEN_TERMINAL_API_KEY_FILE=/tmp/key open-terminal run --host 127.0.0.1
ValueError: Both OPEN_TERMINAL_API_KEY and OPEN_TERMINAL_API_KEY_FILE are set, but they are mutually exclusive.

Seen on 0.14.0; the same lines are on main.

Cause

cli.py run reads OPEN_TERMINAL_API_KEY_FILE (around line 78), then writes the key back with os.environ["OPEN_TERMINAL_API_KEY"] = api_key (line 91). When env.py is imported afterwards, _resolve_file_env("OPEN_TERMINAL_API_KEY") sees both variables set and raises. Only the run path is affected: the _FILE variable is never removed after being consumed.

Suggested fix

In run, remove the _FILE variable once the key has been resolved, next to where OPEN_TERMINAL_API_KEY is set:

os.environ["OPEN_TERMINAL_API_KEY"] = api_key
os.environ.pop("OPEN_TERMINAL_API_KEY_FILE", None)

Then drop the now-redundant _FILE handling from run itself and let env._resolve_file_env be the single place that reads it, so the two code paths can't disagree again.

Originally created by @jamesdury on GitHub (Oct 7, 2026). Original GitHub issue: https://github.com/open-webui/open-terminal/issues/187 `open-terminal run` cannot start when the key is given through `OPEN_TERMINAL_API_KEY_FILE`, the Docker-secrets route `env.py` documents. ## Reproduce ```sh echo secret > /tmp/key OPEN_TERMINAL_API_KEY_FILE=/tmp/key open-terminal run --host 127.0.0.1 ``` ``` ValueError: Both OPEN_TERMINAL_API_KEY and OPEN_TERMINAL_API_KEY_FILE are set, but they are mutually exclusive. ``` Seen on 0.14.0; the same lines are on `main`. ## Cause `cli.py` `run` reads `OPEN_TERMINAL_API_KEY_FILE` (around line 78), then writes the key back with `os.environ["OPEN_TERMINAL_API_KEY"] = api_key` (line 91). When `env.py` is imported afterwards, `_resolve_file_env("OPEN_TERMINAL_API_KEY")` sees both variables set and raises. Only the `run` path is affected: the `_FILE` variable is never removed after being consumed. ## Suggested fix In `run`, remove the `_FILE` variable once the key has been resolved, next to where `OPEN_TERMINAL_API_KEY` is set: ```python os.environ["OPEN_TERMINAL_API_KEY"] = api_key os.environ.pop("OPEN_TERMINAL_API_KEY_FILE", None) ``` Then drop the now-redundant `_FILE` handling from `run` itself and let `env._resolve_file_env` be the single place that reads it, so the two code paths can't disagree again.
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
open-webui/open-terminal#110
No description provided.