Skip to content

Commit 4c69179

Browse files
nciminoclaude
andcommitted
fix(anythingllm): inject required OPENROUTER_API_KEY into container env
The compose files documented OPENROUTER_API_KEY as a required Infisical secret, but the environment block only injected JWT_SECRET and ADMIN_EMAIL — the original Helm chart mounted all three. A redeploy/restore came up with no OpenRouter credential in the container env; for the INT-S004 restore specifically AnythingLLM would fall back to the expired key persisted in the restored storage/.env, breaking inference with an opaque OpenRouter 401. - Add fail-loud `${OPENROUTER_API_KEY:?...}` injection (same pattern as the JWT_SECRET guard) to the template and both live sites (s004.ccc.bot, ai.weown.agency). A value injected via `infisical run` now overrides the stale persisted key. - Default OPENROUTER_MODEL_PREF (`:-anthropic/claude-opus-4.5` in sites, `{{ openrouter_model_pref }}` in the template) to silence the Compose "variable is not set" warning. Validated: template re-renders byte-identical to the s004.ccc.bot site; `docker compose config` resolves the key and defaults, and hard-fails with the guard message when the key is absent. Caught by Copilot review on PR #39. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7e6e11e commit 4c69179

4 files changed

Lines changed: 28 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Changes in this section will be promoted to a dated release entry on merge to `m
6060

6161
### Fixed
6262

63+
- **`OPENROUTER_API_KEY` never injected into the AnythingLLM container across `anythingllm-docker` (2026-06-02)** — the compose files documented `OPENROUTER_API_KEY` as a required Infisical secret, but the `environment:` block only injected `JWT_SECRET` and `ADMIN_EMAIL` (the original Helm chart mounted all three). A redeploy/restore therefore came up with no OpenRouter credential in the container env — and for the INT-S004 restore specifically, AnythingLLM would fall back to the **expired** key persisted in the restored `storage/.env`, breaking inference with an opaque OpenRouter 401. Added a fail-loud `${OPENROUTER_API_KEY:?...}` injection (same pattern as the `JWT_SECRET` guard) to the template (`compose.prod.yaml.jinja`) and both live sites (`s004.ccc.bot`, `ai.weown.agency`); a value injected via `infisical run` now correctly overrides the stale persisted key. Also gave `OPENROUTER_MODEL_PREF` a default (`${OPENROUTER_MODEL_PREF:-anthropic/claude-opus-4.5}` in the sites, `{{ openrouter_model_pref }}` in the template) to silence the Compose "variable is not set" warning. Caught by Copilot review on PR #39.
6364
- **`otel-agent/deploy.yml` broken Jinja escaping (2026-05-23)** — the file is a plain Ansible playbook (not a copier template), but it had been written with `{{ '{{' }} otel_agent_dir {{ '}}' }}` patterns that would render as the literal string `{{ otel_agent_dir }}` and prevent Ansible variable substitution. Replaced with plain `{{ otel_agent_dir }}` throughout.
6465

6566
<!-- ── older 2026-05-14 batch (Added / Changed / Fixed continued) ── -->

anythingllm-docker/sites/ai.weown.agency/docker/compose.prod.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@ services:
2121
STORAGE_DIR: "/app/server/storage"
2222
# LLM Configuration
2323
LLM_PROVIDER: "openrouter"
24-
OPENROUTER_MODEL_PREF: "${OPENROUTER_MODEL_PREF}"
24+
# Fail loud: OpenRouter is the only wired-in provider (LLM_PROVIDER above),
25+
# so the API key is required. A bare `docker compose up` outside
26+
# `infisical run` would inject an empty value, which overrides any key in
27+
# AnythingLLM's persisted storage/.env (dotenv won't re-override a set var)
28+
# and breaks inference with an opaque OpenRouter 401. `:?` makes compose
29+
# refuse to start instead. The original Helm deployment mounted this as a
30+
# required secret env var too.
31+
OPENROUTER_API_KEY: "${OPENROUTER_API_KEY:?refusing to start: OPENROUTER_API_KEY not injected — start via 'infisical run'}"
32+
OPENROUTER_MODEL_PREF: "${OPENROUTER_MODEL_PREF:-anthropic/claude-opus-4.5}"
2533
OPENROUTER_TIMEOUT_MS: "${OPENROUTER_TIMEOUT_MS:-3000}"
2634
# Vector Database (embedded LanceDB)
2735
VECTOR_DB: "lancedb"

anythingllm-docker/sites/s004.ccc.bot/docker/compose.prod.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@ services:
2121
STORAGE_DIR: "/app/server/storage"
2222
# LLM Configuration
2323
LLM_PROVIDER: "openrouter"
24-
OPENROUTER_MODEL_PREF: "${OPENROUTER_MODEL_PREF}"
24+
# Fail loud: OpenRouter is the only wired-in provider (LLM_PROVIDER above),
25+
# so the API key is required. A bare `docker compose up` outside
26+
# `infisical run` would inject an empty value, which overrides any key in
27+
# AnythingLLM's persisted storage/.env (dotenv won't re-override a set var)
28+
# and breaks inference with an opaque OpenRouter 401. `:?` makes compose
29+
# refuse to start instead. The original Helm deployment mounted this as a
30+
# required secret env var too.
31+
OPENROUTER_API_KEY: "${OPENROUTER_API_KEY:?refusing to start: OPENROUTER_API_KEY not injected — start via 'infisical run'}"
32+
OPENROUTER_MODEL_PREF: "${OPENROUTER_MODEL_PREF:-anthropic/claude-opus-4.5}"
2533
OPENROUTER_TIMEOUT_MS: "${OPENROUTER_TIMEOUT_MS:-3000}"
2634
# Vector Database (embedded LanceDB)
2735
VECTOR_DB: "lancedb"

anythingllm-docker/template/docker/compose.prod.yaml.jinja

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@ services:
2121
STORAGE_DIR: "/app/server/storage"
2222
# LLM Configuration
2323
LLM_PROVIDER: "{{ llm_provider }}"
24-
OPENROUTER_MODEL_PREF: "${OPENROUTER_MODEL_PREF}"
24+
# Fail loud: OpenRouter is the only wired-in provider (LLM_PROVIDER above),
25+
# so the API key is required. A bare `docker compose up` outside
26+
# `infisical run` would inject an empty value, which overrides any key in
27+
# AnythingLLM's persisted storage/.env (dotenv won't re-override a set var)
28+
# and breaks inference with an opaque OpenRouter 401. `:?` makes compose
29+
# refuse to start instead. The original Helm deployment mounted this as a
30+
# required secret env var too.
31+
OPENROUTER_API_KEY: "${OPENROUTER_API_KEY:?refusing to start: OPENROUTER_API_KEY not injected — start via 'infisical run'}"
32+
OPENROUTER_MODEL_PREF: "${OPENROUTER_MODEL_PREF:-{{ openrouter_model_pref }}}"
2533
OPENROUTER_TIMEOUT_MS: "${OPENROUTER_TIMEOUT_MS:-3000}"
2634
# Vector Database (embedded LanceDB)
2735
VECTOR_DB: "{{ vector_db }}"

0 commit comments

Comments
 (0)