ops: push-gated CI live (12+2 suites, red-test proven, merge gate on); fail-closed config validators shipped to gateway+chat and proven; three backfilled incident write-ups (yaml outage, Loomio invite blast, stale-image deploy) + the 69-var portal env manifest
This commit is contained in:
1 parent
2c38f4d2c3
commit
206c3d5379
6 files changed
+698
-28
No files matched your search
@@ -0,0 +1,84 @@
|
|||||||
|
# Incident 2026-10-31 — a `customFooter:` key in librechat.yaml kept the chat API from ever starting; the SPA kept serving 200
|
||||||
|
|
||||||
|
Backfilled 2026-11-11 (the incident predates ops-docs' incident practice; the
|
||||||
|
knowledge lived only in the steward skill until the codebase audit flagged the
|
||||||
|
gap). Written from the skill reference, the git history around the footer work
|
||||||
|
and the deployed build's own validator. No values, only names.
|
||||||
|
|
||||||
|
## What happened
|
||||||
|
|
||||||
|
A footer customisation for chat.inference.coop was made by adding a
|
||||||
|
`customFooter:` top-level key to `/app/data/librechat.yaml` (the persistent
|
||||||
|
volume) and restarting the app. LibreChat's config loader runs the yaml
|
||||||
|
through its **strict config schema** (`configSchema.strict()` from
|
||||||
|
`librechat-data-provider`, in `@librechat/api`'s config load) and exits on an
|
||||||
|
unrecognized top-level key:
|
||||||
|
|
||||||
|
```
|
||||||
|
logger.error("Exiting due to invalid configuration. Set CONFIG_BYPASS_VALIDATION=true …");
|
||||||
|
process.exit(1);
|
||||||
|
```
|
||||||
|
|
||||||
|
`customFooter` is not a key of that schema in the deployed build — this build
|
||||||
|
reads the footer **only** from the `CUSTOM_FOOTER` env var. So the API server
|
||||||
|
(node `api/server/index.js`) never came up.
|
||||||
|
|
||||||
|
## Blast radius
|
||||||
|
|
||||||
|
- **Every API route of chat.inference.coop down for members** — login, chat,
|
||||||
|
/api/config, key checks — from the yaml edit + restart until the key was
|
||||||
|
removed and the app restarted again.
|
||||||
|
- The **SPA kept serving HTTP 200**: Cloudron's health check and the homepage
|
||||||
|
stayed green (the static shell is served regardless of the API process), so
|
||||||
|
the app looked "up" on every status surface. Any check that scored the app
|
||||||
|
by a 200 was testing the shell, not the service.
|
||||||
|
- No data loss (config-only; the yaml was fixed in place).
|
||||||
|
|
||||||
|
## Detection gap
|
||||||
|
|
||||||
|
Nothing detected it while members hit it. The failure signature —
|
||||||
|
`/api/config` returning the HTML shell instead of JSON — was only found by a
|
||||||
|
human-side check, and the recovery was scored by exactly that probe
|
||||||
|
afterwards. The gap was twofold:
|
||||||
|
|
||||||
|
1. No pre-boot validation: the yaml was edited on the volume with nothing
|
||||||
|
checking it against the schema before the restart.
|
||||||
|
2. No post-restart behavioural check: a green 200 from a single-page app
|
||||||
|
proves the vhost, not the app.
|
||||||
|
|
||||||
|
## Resolution
|
||||||
|
|
||||||
|
- Removed the `customFooter:` key from `/app/data/librechat.yaml`; the footer
|
||||||
|
was later shipped correctly through `CUSTOM_FOOTER` in `/app/data/env`
|
||||||
|
(the value channel that actually reaches the node process).
|
||||||
|
- Restart → `/api/config` returned JSON again → recovery declared on that
|
||||||
|
evidence, not on the homepage 200.
|
||||||
|
|
||||||
|
## The fix that now exists (2026-11-11)
|
||||||
|
|
||||||
|
The chat image (overlay `librechat-custom`, tag `20261111-179fd7c`) now
|
||||||
|
carries a **fail-closed config validator wired at the top of the boot path**:
|
||||||
|
|
||||||
|
- `validate_config.py` (canonical copy in `ops-docs/scripts/`, shipped
|
||||||
|
byte-identical into the image) runs the deployed build's own strict schema —
|
||||||
|
`configSchema.strict().safeParse()` from the container's
|
||||||
|
`librechat-data-provider` — against `/app/data/librechat.yaml` **before**
|
||||||
|
anything starts.
|
||||||
|
- `patch_start_validator.py` inserts the check into `/app/pkg/start.sh` at
|
||||||
|
build time (idempotent, non-fatal to apply; fatal at runtime **only** when
|
||||||
|
the config is actually invalid).
|
||||||
|
- On an unknown key the boot dies loudly with one line naming the key
|
||||||
|
(`CONFIG VALIDATION FAILED: customFooter: Unrecognized key(s) …`), instead of
|
||||||
|
an API server that never starts behind a healthy-looking shell.
|
||||||
|
|
||||||
|
Proven before deploy: live yaml passes (7 top-level keys accepted); the
|
||||||
|
reproduced outage config (live yaml + `customFooter`) fails naming the key,
|
||||||
|
through both the deployed-schema path and the static fallback; the served
|
||||||
|
`/api/config` is JSON after the deploy.
|
||||||
|
|
||||||
|
## Prevention rules recorded
|
||||||
|
|
||||||
|
- Treat any librechat.yaml key as schema-validated: check it against the
|
||||||
|
deployed build's `configSchema` before writing it to the volume.
|
||||||
|
- After ANY chat config edit or restart, assert `/api/config` returns JSON —
|
||||||
|
never score recovery by a 200 from the SPA shell.
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
# Incident 2026-11-04 — the Loomio sync rehearsal ran against the live services and invited the whole membership
|
||||||
|
|
||||||
|
Backfilled 2026-11-11 (self-reported by the audit's missing-write-ups list).
|
||||||
|
The operator's brief dates this 2026-11-05; the delegation record that fixed it
|
||||||
|
(fixed the same evening) dates the blast itself to 2026-11-04 — that verified
|
||||||
|
date is used here.
|
||||||
|
|
||||||
|
## What happened
|
||||||
|
|
||||||
|
The portal's Loomio integration keeps the co-op's Loomio group in step with the
|
||||||
|
membership: it adds members who join, removes members who deactivate, and
|
||||||
|
notifies by email on invite. A **rehearsal** of the sync/deactivation path was
|
||||||
|
run to verify proposed behaviour. The harness was not made structurally
|
||||||
|
incapable of a write: the function's dependencies pointed at the **live portal
|
||||||
|
database** and the **live Loomio API**, and a rehearsed path calls exactly the
|
||||||
|
path it was given. The rehearsal re-ran a full membership sync against both,
|
||||||
|
and Loomio issued a **whole-group invite notification — ~83 in-app recipients
|
||||||
|
(Loomio notification id 744)** — to essentially the entire membership, plus the
|
||||||
|
invite emails that path sends.
|
||||||
|
|
||||||
|
## Blast radius
|
||||||
|
|
||||||
|
- ~83 members received a redundant Loomio invite notification and its email
|
||||||
|
for a group most of them were already in. No member data was changed
|
||||||
|
destructively (the sync's add path is additive); the damage was a
|
||||||
|
membership-wide bogus notification, and trust.
|
||||||
|
- The portal database was not corrupted; the live Loomio group state ended up
|
||||||
|
correct (the invited people were mostly already members — which is why the
|
||||||
|
notifications were noise, not access changes).
|
||||||
|
|
||||||
|
## Detection gap
|
||||||
|
|
||||||
|
Our own code recorded nothing — a rehearsal leaves no "blast" record in the
|
||||||
|
portal, and the sync had no per-subject send log. The evidence came from the
|
||||||
|
**third party's own notification log** (Loomio's notification 744), not from
|
||||||
|
anything we monitor. A rehearsal that touches live services does not announce
|
||||||
|
itself; only the receiver's records showed it.
|
||||||
|
|
||||||
|
## Resolution (same day, deployed and verified)
|
||||||
|
|
||||||
|
The fix job (`deleg_8b616d58`, completed 2026-11-04 ~19:00 UTC) re-enabled the
|
||||||
|
sync with the guard that was missing and deployed portal image
|
||||||
|
`20261104-c78acf5` (manifest pinned `d945ba1`):
|
||||||
|
|
||||||
|
1. **Idempotent add path** — the sync now checks the destination's actual
|
||||||
|
state before acting: a member already in the Loomio group is never invited
|
||||||
|
or emailed again, no matter how many times the sync runs. The normal
|
||||||
|
schedule keeps admitting genuinely new people.
|
||||||
|
2. **Removal reconciliation preserved** — the guard must not block removals:
|
||||||
|
a deactivated member still propagates (removals verified idempotent too),
|
||||||
|
so the invite guard cannot silently strand lapsed members in the group.
|
||||||
|
3. **Verified by the operation's own class of effect**: 0 notification
|
||||||
|
deliveries after the deploy, group total 84 vs 94 portal members (the only
|
||||||
|
roster email not in the portal is `bot@inference.coop`, the allowlist
|
||||||
|
account, correctly excluded), 26/26 portal tests passing
|
||||||
|
(`tests/test_loomio_guard.py` among them).
|
||||||
|
|
||||||
|
## Root cause
|
||||||
|
|
||||||
|
A rehearsal brief that said "test the sync path" without making production
|
||||||
|
unreachable. "Use a fixture, never the live row" is not a control: any function
|
||||||
|
whose dependencies point at live services WILL act on them. The harness must be
|
||||||
|
*structurally incapable* of a write — stub the network layer, copy the
|
||||||
|
database and point the code at the copy, and **prove the isolation before the
|
||||||
|
harness runs** (assert the stub recorded the call instead of the service
|
||||||
|
receiving it).
|
||||||
|
|
||||||
|
## The fix that now exists
|
||||||
|
|
||||||
|
- The add-path idempotence and preserved removal reconciliation above (in the
|
||||||
|
portal image since 2026-11-04; guarded by `tests/test_loomio_guard.py`, which
|
||||||
|
has run green on every push since 2026-11-11 via Woodpecker).
|
||||||
|
- The standing rule, recorded in the steward skill: a rehearsal brief must make
|
||||||
|
production unreachable, and the boundary must be verified before the harness
|
||||||
|
runs — plus a per-subject send record for any path that notifies, seeded from
|
||||||
|
live state, so a first enabled run cannot re-blast the population it is
|
||||||
|
meant to leave alone.
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
# Incident 2026-11-09 — a gateway deploy shipped the previous build's image; every surface said it succeeded
|
||||||
|
|
||||||
|
Backfilled 2026-11-11 (self-reported by the audit's missing-write-ups list;
|
||||||
|
facts from the steward skill's deploy reference, verified there on 2026-11-09,
|
||||||
|
and re-confirmed by a live recurrence on 2026-11-11 — see the end).
|
||||||
|
|
||||||
|
## What happened
|
||||||
|
|
||||||
|
During the 2026-11-09 gateway upgrade window, the LiteLLM gateway was updated
|
||||||
|
expecting the new build. Two distinct mechanisms of this platform's update
|
||||||
|
path combined to ship the WRONG code while everything reported success:
|
||||||
|
|
||||||
|
1. **`cloudron update --image <tag>` was a silent no-op for this app.** The
|
||||||
|
CLI exited 0, printed `App is updated.`, recreated the container, wrote the
|
||||||
|
tag into the app record — and the running code was unchanged. The builder
|
||||||
|
pushes images to the registry (`registry.inference.coop/<repo>`), never
|
||||||
|
into the host's docker, so a bare `local/…` reference cannot be pulled.
|
||||||
|
`cloudron status --app` also reported the new tag, so **every surface agreed
|
||||||
|
with the lie**.
|
||||||
|
2. **`cloudron update` without `--image` reuses the LAST builder build.** The
|
||||||
|
update does not build on-server; it takes the previous build package. A
|
||||||
|
deploy performed before (or without) a fresh build ships the PREVIOUS
|
||||||
|
commit's image under a fresh manifest. That day: new manifest shipped, old
|
||||||
|
image ran, both looked like success.
|
||||||
|
|
||||||
|
## Blast radius
|
||||||
|
|
||||||
|
- The gateway ran the **previous commit's code** after a deploy that was
|
||||||
|
believed to carry the new code — the deploy's intended change (and any
|
||||||
|
verification done against it) silently proved nothing.
|
||||||
|
- No data loss, no downtime: the old image was healthy. The damage was
|
||||||
|
epistemic — a deploy recorded as done that had not happened, which the next
|
||||||
|
session would have inherited as fact.
|
||||||
|
|
||||||
|
## Detection gap
|
||||||
|
|
||||||
|
`App is updated.` and a green health check are the platform's success story,
|
||||||
|
and they are true even for a wrong deploy. Nothing in the flow forced the
|
||||||
|
question "is the NEW code actually running?" — the check that catches this
|
||||||
|
(grep the RUNNING container for something only the new code contains) existed
|
||||||
|
as a rule but was not wired into the deploy itself.
|
||||||
|
|
||||||
|
## Resolution and the fix that now exists
|
||||||
|
|
||||||
|
The working deploy order, verified 2026-11-09 and again 2026-11-11:
|
||||||
|
|
||||||
|
1. **Commit first** — the build context is the git checkout; an uncommitted
|
||||||
|
overlay edit silently reverts on rebuild.
|
||||||
|
2. **Build FIRST**, always, via
|
||||||
|
`~/.hermes/scripts/cloudron_builder_build.sh <repository> <yyyymmdd>-<gitsha>`
|
||||||
|
from the app's OWN repo dir (the auth triple is not optional).
|
||||||
|
3. **Then update**: for an app whose repo manifest pins `dockerImage`
|
||||||
|
(librechat-custom, member-portal), write the built tag into the manifest,
|
||||||
|
commit, and `cloudron update --app <id> --force` (no `--image` — the pin
|
||||||
|
wins). For an app with NO pin (litellm's local/… manifest), update from the
|
||||||
|
app's own repo dir; a bare `--image` with a non-registry path is a no-op.
|
||||||
|
4. **Verify two facts, never the CLI's output**: the app record's
|
||||||
|
`manifest.dockerImage` equals the built tag, AND the running container
|
||||||
|
contains something only the new build produces (`cloudron exec --app <id> --
|
||||||
|
grep -c <marker> <path>` / an md5 of a changed file / a boot-log line the
|
||||||
|
new start path prints).
|
||||||
|
|
||||||
|
Rollback is the same command with the previous tag — record the running tag
|
||||||
|
before any deploy.
|
||||||
|
|
||||||
|
## Recurrence caught live (2026-11-11) — the trap is broader than "stale"
|
||||||
|
|
||||||
|
The 2026-11-11 validator deploys hit the same mechanism from the other side:
|
||||||
|
a **bare `cloudron update --app <gateway-id> --force`** (no `--image`, run
|
||||||
|
from a neutral cwd, with no pin in the gateway manifest) deployed **the last
|
||||||
|
build package globally — which was a different app's build** (the chat
|
||||||
|
overlay), replacing the gateway's image AND installed manifest. The app
|
||||||
|
reported healthy the whole time because the wrong image was itself a healthy
|
||||||
|
web app; the deploy verification battery (manifest tag check) caught it
|
||||||
|
within minutes and the gateway was redeployed correctly with an explicit
|
||||||
|
registry-path `--image` from its own repo dir (downtime ≈ 9 minutes,
|
||||||
|
03:55–04:04 UTC).
|
||||||
|
|
||||||
|
Standing rules this recurrence adds:
|
||||||
|
|
||||||
|
- A bare `cloudron update` deploys the LAST BUILD PACKAGE — manifest
|
||||||
|
included — and the "last build" tracking is **global, not per-app**. Never
|
||||||
|
run it for an app whose own build was not the immediately preceding build.
|
||||||
|
- An app whose manifest has no `dockerImage` pin must be updated from its own
|
||||||
|
repo directory; `--image` takes the full registry path
|
||||||
|
(`registry.inference.coop/<repo>:<tag>`), never a bare `local/…` reference.
|
||||||
|
- The two-fact verification (manifest tag + in-container marker) is what turns
|
||||||
|
this trap from an incident into a caught-in-minutes event; do the second
|
||||||
|
fact every time.
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
# Woodpecker CI (server + agent)
|
# Woodpecker CI (server + agent)
|
||||||
|
|
||||||
Self-hosted CI for the co-op's repos. **As of 2026-11-04 the CI is installed but
|
Self-hosted CI for the co-op's repos. **As of 2026-11-11 the CI is WORKING
|
||||||
NOT working end to end** — read the *Current state* section before trusting it for
|
end to end for push-gated test runs** — `co-op/docs` (manual, build+deploy),
|
||||||
anything.
|
`code/member-portal` and `code/admin-panel` (push-triggered test gating). Read
|
||||||
|
the *Current state* section for what is proven and the traps that remain.
|
||||||
|
|
||||||
Two Cloudron apps, added 2026-11-03:
|
Two Cloudron apps, added 2026-11-03:
|
||||||
|
|
||||||
@@ -54,41 +55,66 @@ CLI, and a pinned MkDocs toolchain at `/opt/docs-venv`. It **runs as root**
|
|||||||
`publishing/requirements.txt`; **keep the two in step** when the docs toolchain
|
`publishing/requirements.txt`; **keep the two in step** when the docs toolchain
|
||||||
changes.
|
changes.
|
||||||
|
|
||||||
|
## Current state (2026-11-11): push-gated test CI is live
|
||||||
|
|
||||||
|
- **The server-side gRPC 500 was never the blocker.** The agent's `Next`
|
||||||
|
long-poll is cut short by the platform proxy every ~10 minutes (nginx
|
||||||
|
`upstream timed out`, `could not find named location "@grpc_unavailable"`)
|
||||||
|
and the agent retries — pipelines are collected and executed regardless.
|
||||||
|
Re-confirmed 2026-11-11: the 500s continue in the log while push-triggered
|
||||||
|
pipelines run green. Do not chase it.
|
||||||
|
- **API access:** a personal token for `inference-admin` lives at
|
||||||
|
`/home/ubuntu/.hermes/woodpecker.key` (mode 600). Repo enablement is
|
||||||
|
`POST /api/repos?forge_remote_id=<gitea repo id>` (query param, not body);
|
||||||
|
a manual run is `POST /api/repos/<id>/pipelines` with `{"branch": "..."}`.
|
||||||
|
- **Enabled repos:** `co-op/docs` (id 1), `code/member-portal` (id 2),
|
||||||
|
`code/admin-panel` (id 3). Note `co-op/member-portal` is a Gitea REDIRECT to
|
||||||
|
`code/member-portal` — the canonical repo lives in the `code` org (Gitea id 6).
|
||||||
|
- **Test gating (added 2026-11-11):** `.woodpecker.yml` on both apps' default
|
||||||
|
branches runs their EXISTING suites on every push (12 portal test files;
|
||||||
|
admin-panel guest-guard test + 4 page-JS harnesses via the vendored
|
||||||
|
`tests/check-page-js.sh`). Gitea branch protection on `main` of both repos
|
||||||
|
now requires the status context `ci/woodpecker/push/woodpecker` to merge.
|
||||||
|
- **Proven with real output:** first push runs green (portal tests step: 439
|
||||||
|
log lines ending "all portal test suites green"; all four harnesses OK on
|
||||||
|
the panel), and a deliberately broken assertion on a branch (`ci-red-test`)
|
||||||
|
produced pipeline #2 **failure** with the failing status context on Gitea —
|
||||||
|
the gate signal works. The branch was deleted after the proof.
|
||||||
|
- **The agent's python is 3.14** (agent image base) — the portal's PINNED
|
||||||
|
requirements (pydantic 2.9.2, psycopg2-binary 2.9.9) have no cp314 wheels,
|
||||||
|
so the portal pipeline installs a bounded-range subset (fastapi/httpx/PyJWT/
|
||||||
|
slowapi/cryptography) instead of `-r requirements.txt`. See
|
||||||
|
`code/member-portal/.woodpecker.yml` for the rationale.
|
||||||
|
|
||||||
## When a pipeline runs (and when it does not)
|
## When a pipeline runs (and when it does not)
|
||||||
|
|
||||||
- **Manual-trigger only.** Nothing here fires on push; a pipeline is started by
|
- `co-op/docs`: **manual-trigger only** by deliberate decision (the poll
|
||||||
hand from the Woodpecker UI.
|
watcher remains the live auto-deploy path until the operator says otherwise).
|
||||||
- **The pipeline is not yet green end to end.**
|
- `code/member-portal`, `code/admin-panel`: fire on every **push** (any
|
||||||
|
branch) and can also be triggered manually.
|
||||||
- **`git-lfs` is required by the clone step.** Woodpecker runs `git lfs fetch`
|
- **`git-lfs` is required by the clone step.** Woodpecker runs `git lfs fetch`
|
||||||
after cloning, so a clone step fails with
|
after cloning, so a clone step fails with
|
||||||
`git: 'lfs' is not a git command` on any image without it — this was added to
|
`git: 'lfs' is not a git command` on any image without it — this was added to
|
||||||
the agent image on 2026-11-04. If a rebuild ever drops it, clones break again.
|
the agent image on 2026-11-04. If a rebuild ever drops it, clones break again.
|
||||||
|
|
||||||
## Current state (2026-11-04): installed, agent connected, cannot run jobs
|
## Historical state (2026-11-04): installed, agent connected, could not run jobs
|
||||||
|
|
||||||
- The server is up — `https://ci.inference.coop/` serves the Woodpecker UI.
|
Superseded by the section above. Kept because each entry was a lesson:
|
||||||
- The agent app is `running`/`healthy` and its health endpoint answers — **but
|
the health endpoint lied by omission (liveness, not capability), the missing
|
||||||
that is liveness, not capability.** The log shows the agent's **gRPC job-collection
|
git-lfs broke every clone, the missing repo secret (`cloudron_token`) made the
|
||||||
long-poll failing continuously**: the server answers the agent's RPC with
|
config fail to PARSE with the reason visible ONLY in the web UI, and the gRPC
|
||||||
**HTTP 500** (an nginx `text/html` 500 body), so the agent retries with backoff
|
500s were misread twice as the blocker before pipeline #2 proved otherwise.
|
||||||
and **never receives work**.
|
The repo-enablement login gate (operator completes Gitea OAuth once) was
|
||||||
- A healthy agent that cannot collect jobs is the exact trap to avoid reading as
|
cleared the same day: the `inference-admin` user exists with admin rights.
|
||||||
progress. Score a CI worker by **the route that delivers it work**, not by its
|
|
||||||
health RPC.
|
|
||||||
|
|
||||||
**Unresolved / needs an operator:** the server-side gRPC 500. Until the server
|
## Enabling a repo (known gate — cleared 2026-11-04)
|
||||||
answers the agent's stream, no pipeline can execute regardless of repository
|
|
||||||
configuration. This is a server-side (or platform-proxy) problem, not an agent
|
|
||||||
image problem.
|
|
||||||
|
|
||||||
## Enabling a repo (known gate)
|
- Repos are connected through the **Gitea** source (`WOODPECKER_GITEA`). The
|
||||||
|
OAuth login source was stood up by the operator and the `inference-admin`
|
||||||
- Repos are connected through the **Gitea** source (`WOODPECKER_GITEA`). Enabling
|
user exists (admin). Enabling further repos is now a pure API call (see
|
||||||
a repo requires the repo owner to log in to Woodpecker with **Gitea OAuth** and
|
*Current state*), not an operator step.
|
||||||
activate it. Standing up that OAuth login source is an **operator step**
|
|
||||||
(creating the Gitea OAuth application needs `write:user`, which the bot's Gitea
|
|
||||||
token does not have).
|
|
||||||
- Reading run/pipeline state is done from the server's **MySQL** database, not
|
- Reading run/pipeline state is done from the server's **MySQL** database, not
|
||||||
from a public API.
|
from a public API, when the API view is thin (the pipeline endpoint does not
|
||||||
|
expose step logs; `log_entries` in the database does).
|
||||||
- Note: the whole point of this CI is to take the docs build and custom-app builds
|
- Note: the whole point of this CI is to take the docs build and custom-app builds
|
||||||
off the agent host — see `co-op/support#30` (moving `REGISTRY_BUILD_TOKEN` to CI).
|
off the agent host — see `co-op/support#30` (moving `REGISTRY_BUILD_TOKEN` to CI).
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
# Reference — Member portal environment-variable manifest
|
||||||
|
|
||||||
|
Generated 2026-11-11 from the RUNNING portal container's environment (69 vars,
|
||||||
|
read as NAMES only — no values were printed or committed), the portal source
|
||||||
|
(`app/main.py` reads at the line numbers cited), and fingerprint comparison
|
||||||
|
(`sha256`[:8]) between the portal's copies and each owner app's own
|
||||||
|
credential. Companion to the incident
|
||||||
|
[`2026-11-05-portal-alltime-spend-zero.md`](../incidents/2026-11-05-portal-alltime-spend-zero.md),
|
||||||
|
which is why the copy-pattern secrets carry a warning.
|
||||||
|
|
||||||
|
Reading guide:
|
||||||
|
|
||||||
|
- **Source** — where the value comes from at runtime:
|
||||||
|
`platform` = injected by Cloudron (not in any repo, do not set by hand);
|
||||||
|
`app env` = set on the portal app via the Cloudron env API / dashboard
|
||||||
|
(42 vars; the authoritative values live in the platform, never in git);
|
||||||
|
`image` = baked in by the base python image, irrelevant to the app.
|
||||||
|
- **Class** — `SECRET` (credential: treat as rotation-sensitive),
|
||||||
|
`IDENT` (identifier/URL: safe-ish, still internal), `CONFIG` (behaviour flag).
|
||||||
|
- **COPY** — the value is a *copy* of another app's or system's credential.
|
||||||
|
A rotation or restore on the OWNER side silently rots the copy (proven by the
|
||||||
|
2026-11-05 incident). After any owner-side restore/rotation, re-sync the copy
|
||||||
|
and diff fingerprints — never values.
|
||||||
|
|
||||||
|
## 1. Platform-injected (27) — never set by hand
|
||||||
|
|
||||||
|
| Name | Source | Class | Read by portal | Notes |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| `CLOUDRON_API_ORIGIN` | platform | IDENT | yes (L198) | Cloudron API base the portal calls for OIDC user lookups |
|
||||||
|
| `CLOUDRON_APP_BRIDGE_ORIGIN` | platform | IDENT | no | platform plumbing |
|
||||||
|
| `CLOUDRON_APP_DOMAIN` | platform | IDENT | no | portal.inference.coop |
|
||||||
|
| `CLOUDRON_APP_HOSTNAME` | platform | IDENT | no | platform plumbing |
|
||||||
|
| `CLOUDRON_APP_ORIGIN` | platform | IDENT | no | platform plumbing |
|
||||||
|
| `CLOUDRON_MAIL_DOMAIN` | platform | IDENT | no | platform plumbing |
|
||||||
|
| `CLOUDRON_MAIL_FROM` | platform | IDENT | yes (L474) | From identity for portal mail (default `info@inference.coop`) |
|
||||||
|
| `CLOUDRON_MAIL_SMTP_PASSWORD` | platform | SECRET | yes (L473) | Cloudron mail addon relay password |
|
||||||
|
| `CLOUDRON_MAIL_SMTP_PORT` | platform | IDENT | yes (L471) | relay submission port |
|
||||||
|
| `CLOUDRON_MAIL_SMTP_SERVER` | platform | IDENT | yes (L470) | relay host |
|
||||||
|
| `CLOUDRON_MAIL_SMTP_USERNAME` | platform | SECRET | yes (L472) | relay user |
|
||||||
|
| `CLOUDRON_MAIL_SMTPS_PORT` | platform | IDENT | no | platform plumbing |
|
||||||
|
| `CLOUDRON_MAIL_STARTTLS_PORT` | platform | IDENT | no | platform plumbing |
|
||||||
|
| `CLOUDRON_OIDC_AUTH_ENDPOINT` | platform | IDENT | no | read via OIDC discovery, not directly |
|
||||||
|
| `CLOUDRON_OIDC_CLIENT_ID` | platform | IDENT | no | via discovery |
|
||||||
|
| `CLOUDRON_OIDC_CLIENT_SECRET` | platform | SECRET | no | consumed by the OIDC discovery flow |
|
||||||
|
| `CLOUDRON_OIDC_DISCOVERY_URL` | platform | IDENT | no | via discovery |
|
||||||
|
| `CLOUDRON_OIDC_ISSUER` | platform | IDENT | no | via discovery |
|
||||||
|
| `CLOUDRON_OIDC_KEYS_ENDPOINT` | platform | IDENT | no | via discovery |
|
||||||
|
| `CLOUDRON_OIDC_PROFILE_ENDPOINT` | platform | IDENT | no | via discovery |
|
||||||
|
| `CLOUDRON_OIDC_PROVIDER_NAME` | platform | IDENT | no | via discovery |
|
||||||
|
| `CLOUDRON_OIDC_TOKEN_ENDPOINT` | platform | IDENT | no | via discovery |
|
||||||
|
| `CLOUDRON_PROXY_IP` | platform | IDENT | no | platform plumbing |
|
||||||
|
| `CLOUDRON_TOKEN` | platform | **SECRET (high)** | yes (L199) | a Cloudron **API token inside an app env** — the portal calls the Cloudron API for group membership. Scope is broader than the app needs; treat as platform-level credential. Owner: the Cloudron platform |
|
||||||
|
| `CLOUDRON_WEBADMIN_ORIGIN` | platform | IDENT | no | platform plumbing |
|
||||||
|
| `GPG_KEY` / `PYTHON_VERSION` / `PYTHON_SHA256` | image | IDENT | no | base python image metadata, not the app's |
|
||||||
|
|
||||||
|
## 2. Portal app env (42) — set via the Cloudron env API
|
||||||
|
|
||||||
|
**The portal's own secrets:**
|
||||||
|
|
||||||
|
| Name | Class | Purpose | Notes |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `PORTAL_KEK` | SECRET | key-encryption key wrapping member API keys at rest (L44) | owner: portal. Loss = re-provision every member key |
|
||||||
|
| `PORTAL_SECRET` | SECRET | portal session/token signing (L206) | owner: portal |
|
||||||
|
| `ADMIN_TOKEN` | SECRET | `/admin/*` API auth (L252) | consumed by the panel, dashboard and the daily digest |
|
||||||
|
| `ADMIN_TOKEN_LEGACY` | CONFIG | accepts the legacy admin token alongside `ADMIN_TOKEN` (L253) | `"0"` disables; delete after the panel/dashboard stop sending the old one |
|
||||||
|
| `BROKER_SECRET` | SECRET | member-API broker auth (L234) | owner: portal |
|
||||||
|
| `WEBHOOK_TOKEN` | SECRET | inbound webhook auth (L239) | owner: portal |
|
||||||
|
|
||||||
|
**COPIES of another system's credentials — the two-copies-of-one-secret risk:**
|
||||||
|
|
||||||
|
| Name | Class | Purpose | COPY of (owner) | Risk |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| `LITELLM_DB_HOST`/`_PORT`/`_USER`/`_NAME`/`_PASSWORD` | SECRET/IDENT | direct Postgres read of LiteLLM's ledger for all-time spend, usage, leaderboard (L496–500) | the **gateway's** `CLOUDRON_POSTGRESQL_*` addon env (fingerprint-verified SAME 2026-11-11) | rotates on every gateway restore; rotted 2026-11-05 → $0 spend shown for 2h20m. After any gateway restore: re-sync + fingerprint-diff. Standing alarm: the digest's SPEND CONSISTENCY check reads the gateway side, not this copy |
|
||||||
|
| `LITELLM_MASTER_KEY` | SECRET | gateway admin API calls from the portal (key seeding, budget caps) (L201) | the **gateway's** `/app/data/.master_key` (fingerprint-verified SAME 2026-11-11: `2cd3668d`) | same rot rule: re-sync after gateway restores |
|
||||||
|
| `MATRIX_BOT_TOKEN` | SECRET | portal's Matrix bot: invites, space sync, welcome DMs (L441) | the **Synapse server's** registration of the portal bot (matrix.inference.coop) | rotation lives server-side; the copy rots silently |
|
||||||
|
| `LIBRECHAT_SYNC_TOKEN` | SECRET | token the **key-sync job shares back** — portal `/admin/librechat/keys` requires it (L7645) | shared with the chat app's `sync-keys.js` (chat.inference.coop) | two holders, one value; rotate both together |
|
||||||
|
| `LISTMONK_API_TOKEN` / `LISTMONK_API_USER` | SECRET | newsletter list sync (L489–490) | the **Listmonk app's** API credentials (newsletter.inference.coop) | owner-side rotation rots the copy |
|
||||||
|
| `LOOMIO_API_KEY` / `LOOMIO_B3_KEY` | SECRET | Loomio membership + B3 user API (L420, L425) | the **Loomio app's** API keys (forum.inference.coop) | owner-side rotation rots the copy; the 2026-11-04 invite blast came from this integration running live (see that incident) |
|
||||||
|
| `OC_PERSONAL_TOKEN` | SECRET | Open Collective GraphQL: payments, orders (L331) | the co-op's **Open Collective** account token (external) | external owner; scope-check on rotation |
|
||||||
|
| `OWUI_API_KEY` / `OWUI_JWT_SECRET` | SECRET | legacy Open WebUI integration (L213, L220) | **chat-legacy.inference.coop** (retired for members 2026-11-02; app kept) | chat-legacy has no `OWUI_API_KEY` env — the copy is one-sided/stale. Vestigial; candidate for removal with the OWUI reads |
|
||||||
|
|
||||||
|
**Identifiers and config (non-secret):**
|
||||||
|
|
||||||
|
| Name | Class | Purpose |
|
||||||
|
|---|---|---|
|
||||||
|
| `ADMIN_INVITER_EMAIL`-adjacent `ADMIN_*` — see above | — | — |
|
||||||
|
| `LITELLM_BASE` | IDENT | gateway base URL (L200, default `https://gateway.inference.coop`) |
|
||||||
|
| `MATRIX_HOMESERVER` | IDENT | homeserver base (L440) |
|
||||||
|
| `MATRIX_SPACE_ID` | IDENT | the co-op Space the sync manages (L442) |
|
||||||
|
| `MATRIX_GENERAL_ROOM` | IDENT | General room id for welcomes (L443) |
|
||||||
|
| `MATRIX_INVITE_ROOMS` | CONFIG | rooms every new member is invited to (L451) |
|
||||||
|
| `MATRIX_EXTRA_ROOMS` | CONFIG | additional rooms the bot watches (L454) |
|
||||||
|
| `MEMBERS_GROUP_ID` | IDENT | Cloudron group id for active members (L401) |
|
||||||
|
| `INACTIVE_GROUP_ID` | IDENT | Cloudron group id for deactivated members (L405) |
|
||||||
|
| `GUESTS_GROUP_ID` / `GUESTS_ENDED_GROUP_ID` | IDENT | guest / ended-guest Cloudron groups (L368, L378) |
|
||||||
|
| `MEMBER_BUDGET` | CONFIG | monthly member allowance in USD (L336, default 15.0) |
|
||||||
|
| `MANUAL_MEMBERS` | CONFIG | comma-separated members exempt from payment checks (L413) |
|
||||||
|
| `ALLOWANCE_POLICY` | CONFIG | allowance lapse policy: `report` (default) / `off` / `on` (L6514) |
|
||||||
|
| `ALLOWANCE_SHORTFALL_EMAILS` | CONFIG | shortfall mail flag `off`/`dryrun`/`on` (L7147) |
|
||||||
|
| `BUDGET_NOTICES` | CONFIG | budget-notice mail flag (L7748) |
|
||||||
|
| `DOCS_KNOWLEDGE_ID` | IDENT | docs-RAG knowledge-base id (L228, has default) |
|
||||||
|
| `LISTMONK_LIST_ID` | IDENT | "Members" list id (L491, default 3) |
|
||||||
|
| `LOOMIO_GROUP_ID` | IDENT | the co-op's Loomio group (L455) |
|
||||||
|
| `OWUI_BASE` | IDENT | legacy chat base URL (L221, default `http://chat:8080`) |
|
||||||
|
| `OWUI_MEMBERS_GROUP_ID` | IDENT | legacy OWUI members group (L222, has default) |
|
||||||
|
|
||||||
|
## 3. Read by code but UNSET (20) — behaviour comes from in-code defaults
|
||||||
|
|
||||||
|
These never appear in the container env; each has a default in `app/main.py`.
|
||||||
|
Documented so the defaults are discoverable (this closes the audit's
|
||||||
|
"undocumented env vars" gap). To change one, ADD it to the portal app env —
|
||||||
|
the code's `os.environ.get(name, default)` picks it up on restart.
|
||||||
|
|
||||||
|
`ADMIN_INVITER_EMAIL`, `ALLOWANCE_DEACTIVATE`, `BUDGET_NOTICE_AT`,
|
||||||
|
`CREDIT_PACK_URL`, `DB_PATH`, `GUEST_BUDGET`, `GUEST_DAYS`,
|
||||||
|
`GUEST_PER_INVITER_DAYS`, `LISTMONK_BASE`, `LOOMIO_ALWAYS_KEEP`,
|
||||||
|
`LOOMIO_BASE`, `LOOMIO_SYNC_ENABLED`, `MAIL_REPLY_TO`,
|
||||||
|
`MATRIX_EXTRA_MXIDS`, `MONEY_SERIES_TTL`, `OC_COLLECTIVE_SLUG`,
|
||||||
|
`OPERATOR_EMAILS`, `PAYMENT_GRACE_DAYS`, `PORTAL_BASE`, `REINVITE_AFTER_DAYS`.
|
||||||
|
|
||||||
|
## Maintenance rules
|
||||||
|
|
||||||
|
1. **No secret value belongs in any repo or doc.** This manifest intentionally
|
||||||
|
documents names, classes and *fingerprints at a point in time* — nothing else.
|
||||||
|
2. **Rotation order** (skill: never lock yourself out): prove the NEW credential
|
||||||
|
works against its owner service, then update the copy, then revoke the old.
|
||||||
|
3. **After any app restore**: fingerprint-diff every COPY row's owner side
|
||||||
|
against the portal copy and re-sync what differs (the 2026-11-05 playbook).
|
||||||
|
4. **De-duplication (flagged, deliberately not done 2026-11-05):** the
|
||||||
|
`LITELLM_DB_*` + `LITELLM_MASTER_KEY` copies exist because the portal reads
|
||||||
|
the ledger directly. The long-term fix — one source of truth, or a
|
||||||
|
gateway-side read-only aggregation endpoint — is recorded in the incident
|
||||||
|
doc and stays open until someone does it deliberately.
|
||||||
@@ -0,0 +1,261 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Fail-closed config validator for the co-op's gateway and chat apps.
|
||||||
|
|
||||||
|
ONE script, two modes, shared home in ops-docs/scripts/ and shipped
|
||||||
|
byte-identical into both app images (litellm repo root, librechat-custom repo
|
||||||
|
root). Each app's start path calls it before booting the service; a non-zero
|
||||||
|
exit refuses the boot with a ONE-line error naming the offending key.
|
||||||
|
|
||||||
|
Why this exists: the 2026-10-31 chat outage. A `customFooter:` top-level key in
|
||||||
|
librechat.yaml was rejected by LibreChat's strict config validator and the API
|
||||||
|
server refused to start, while the SPA kept being served with HTTP 200 — the
|
||||||
|
app looked up but every API route returned the HTML shell. Nothing had ever
|
||||||
|
checked the config before boot. This validator closes that gap: invalid config
|
||||||
|
fails LOUD and EARLY, at the top of the boot log, naming the key.
|
||||||
|
|
||||||
|
Modes
|
||||||
|
-----
|
||||||
|
litellm Structural check of the gateway's config.yaml:
|
||||||
|
- top-level keys within LiteLLM's documented config surface;
|
||||||
|
- model_list present and well-formed (model_name + litellm_params.model);
|
||||||
|
- the settings blocks are objects; pass_through_endpoints entries have paths.
|
||||||
|
When the gateway's own litellm package is importable it is additionally
|
||||||
|
used to resolve every model string to a provider (catches unknown
|
||||||
|
provider prefixes); the check is skipped with a note where litellm
|
||||||
|
itself is absent.
|
||||||
|
|
||||||
|
librechat Checks librechat.yaml against the DEPLOYED build's own strict schema:
|
||||||
|
it runs `configSchema.strict().safeParse()` from the container's
|
||||||
|
librechat-data-provider via node — the same code the API server runs
|
||||||
|
at boot (its failure mode is `process.exit(1)`, "Exiting due to
|
||||||
|
invalid configuration"). Unrecognized top-level keys are rejected,
|
||||||
|
named explicitly. Where node/the package cannot be found (e.g. this
|
||||||
|
script run from a checkout instead of the image) it falls back to a
|
||||||
|
static top-level allowlist recorded from the deployed build and says
|
||||||
|
so on the failure line.
|
||||||
|
|
||||||
|
Usage
|
||||||
|
-----
|
||||||
|
python3 validate_config.py litellm /app/data/config.yaml
|
||||||
|
python3 validate_config.py librechat /app/data/librechat.yaml
|
||||||
|
|
||||||
|
Exit codes: 0 valid, 1 invalid, 2 usage/environment error (file unreadable,
|
||||||
|
yaml unparseable). Never prints a value from the config — only key names and
|
||||||
|
counts, so it is safe to run against files that carry secrets.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# LiteLLM's documented top-level config surface (proxy config). Unknown keys
|
||||||
|
# are rejected here — the gateway should never silently ignore a mistyped
|
||||||
|
# section (a "model-list:" typo would otherwise deploy an EMPTY catalog).
|
||||||
|
LITELLM_TOP_LEVEL = {
|
||||||
|
"model_list",
|
||||||
|
"router_settings",
|
||||||
|
"litellm_settings",
|
||||||
|
"general_settings",
|
||||||
|
"settings",
|
||||||
|
"environment_variables",
|
||||||
|
"guardrails",
|
||||||
|
"files",
|
||||||
|
}
|
||||||
|
|
||||||
|
# Fallback allowlist for librechat mode, recorded 2026-11-11 from the DEPLOYED
|
||||||
|
# build (chat.inference.coop, overlay 1.4.8) by reading
|
||||||
|
# configSchema.strict().shape keys. The live schema is always preferred; this
|
||||||
|
# exists so the validator still fails closed when run outside the container.
|
||||||
|
LIBRECHAT_TOP_LEVEL_FALLBACK = {
|
||||||
|
"actions", "balance", "cache", "cloudfront", "endpoints", "fileConfig",
|
||||||
|
"fileStrategies", "fileStrategy", "filteredTools", "filters",
|
||||||
|
"imageOutputType", "includedTools", "interface", "langfuse", "mcpServers",
|
||||||
|
"mcpSettings", "memory", "messageFilter", "modelSpecs", "ocr", "openapi",
|
||||||
|
"permissions", "rateLimits", "registration", "secureImageLinks",
|
||||||
|
"skillSync", "speech", "summarization", "transactions", "turnstile",
|
||||||
|
"version", "webSearch",
|
||||||
|
}
|
||||||
|
|
||||||
|
LC_DATA_PROVIDER_DIST = os.environ.get(
|
||||||
|
"LC_DATA_PROVIDER_DIST",
|
||||||
|
"/app/code/librechat/packages/data-provider/dist/index.js")
|
||||||
|
LC_JS_YAML = os.environ.get(
|
||||||
|
"LC_JS_YAML", "/app/code/librechat/node_modules/js-yaml")
|
||||||
|
|
||||||
|
|
||||||
|
def fail(key, reason):
|
||||||
|
"""ONE line, naming the offending key, then a non-zero exit."""
|
||||||
|
print(f"CONFIG VALIDATION FAILED: {key}: {reason}", flush=True)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def load_yaml(path):
|
||||||
|
try:
|
||||||
|
import yaml
|
||||||
|
except ImportError:
|
||||||
|
print("CONFIG VALIDATION FAILED: pyyaml not available in this python",
|
||||||
|
flush=True)
|
||||||
|
sys.exit(2)
|
||||||
|
try:
|
||||||
|
with open(path) as fh:
|
||||||
|
data = yaml.safe_load(fh)
|
||||||
|
except FileNotFoundError:
|
||||||
|
print(f"CONFIG VALIDATION FAILED: config file not found: {path}",
|
||||||
|
flush=True)
|
||||||
|
sys.exit(2)
|
||||||
|
except PermissionError:
|
||||||
|
print(f"CONFIG VALIDATION FAILED: config file unreadable: {path}",
|
||||||
|
flush=True)
|
||||||
|
sys.exit(2)
|
||||||
|
except yaml.YAMLError as exc:
|
||||||
|
# Do not echo the raw yaml error: it can quote a secret-bearing line.
|
||||||
|
print("CONFIG VALIDATION FAILED: (root): yaml does not parse",
|
||||||
|
flush=True)
|
||||||
|
sys.exit(2)
|
||||||
|
if data is None:
|
||||||
|
data = {}
|
||||||
|
if not isinstance(data, dict):
|
||||||
|
fail("(root)", "top level must be a mapping")
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
def validate_litellm(path):
|
||||||
|
cfg = load_yaml(path)
|
||||||
|
unknown = sorted(set(cfg) - LITELLM_TOP_LEVEL)
|
||||||
|
if unknown:
|
||||||
|
fail(", ".join(unknown), "unknown top-level key(s) for litellm "
|
||||||
|
f"(allowed: {', '.join(sorted(LITELLM_TOP_LEVEL))})")
|
||||||
|
|
||||||
|
model_list = cfg.get("model_list")
|
||||||
|
if not isinstance(model_list, list) or not model_list:
|
||||||
|
fail("model_list", "must be a non-empty list of model entries")
|
||||||
|
names = set()
|
||||||
|
for i, entry in enumerate(model_list):
|
||||||
|
if not isinstance(entry, dict):
|
||||||
|
fail(f"model_list[{i}]", "entry must be a mapping")
|
||||||
|
name = entry.get("model_name")
|
||||||
|
params = entry.get("litellm_params")
|
||||||
|
if not name or not isinstance(name, str):
|
||||||
|
fail(f"model_list[{i}].model_name", "missing or empty")
|
||||||
|
if name in names:
|
||||||
|
fail(f"model_list[{i}].model_name", f"duplicate model_name {name!r}")
|
||||||
|
names.add(name)
|
||||||
|
if not isinstance(params, dict) or not params.get("model"):
|
||||||
|
fail(f"model_list[{i}].litellm_params.model", "missing or empty")
|
||||||
|
for block in ("router_settings", "litellm_settings", "general_settings"):
|
||||||
|
if block in cfg and not isinstance(cfg[block], dict):
|
||||||
|
fail(block, "must be a mapping")
|
||||||
|
for ep in (cfg.get("general_settings") or {}).get("pass_through_endpoints") or []:
|
||||||
|
if not isinstance(ep, dict) or not ep.get("path"):
|
||||||
|
fail("general_settings.pass_through_endpoints", "each entry needs a path")
|
||||||
|
|
||||||
|
# litellm-assisted check (best effort): resolve each model string to a
|
||||||
|
# provider with the gateway's own package. Skipped where litellm itself
|
||||||
|
# is not importable (never fatal — the structural checks above ran).
|
||||||
|
try:
|
||||||
|
from litellm import get_llm_provider # noqa: WPS433
|
||||||
|
except Exception:
|
||||||
|
print("note: litellm not importable here; provider check skipped",
|
||||||
|
flush=True)
|
||||||
|
else:
|
||||||
|
for entry in model_list:
|
||||||
|
model = entry["litellm_params"]["model"]
|
||||||
|
try:
|
||||||
|
get_llm_provider(model=model, custom_llm_provider=None)
|
||||||
|
except Exception as exc:
|
||||||
|
short = str(exc).split("\n")[0][:120]
|
||||||
|
fail(f"model_list.{entry['model_name']}.litellm_params.model",
|
||||||
|
f"not resolvable to a provider: {short}")
|
||||||
|
|
||||||
|
print(f"config OK (litellm): {len(cfg)} top-level key(s), "
|
||||||
|
f"{len(model_list)} model(s) validated", flush=True)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
def validate_librechat(path):
|
||||||
|
cfg = load_yaml(path)
|
||||||
|
if not cfg:
|
||||||
|
print("config OK (librechat): empty config, nothing to validate",
|
||||||
|
flush=True)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
# Preferred: the DEPLOYED build's own strict schema, run through node —
|
||||||
|
# the exact code path the API server uses at boot (strict() rejects
|
||||||
|
# unrecognized top-level keys; upstream then exits 1).
|
||||||
|
node_code = r"""
|
||||||
|
const fs = require('fs');
|
||||||
|
let out = {mode: 'schema'};
|
||||||
|
try {
|
||||||
|
const yaml = require(JS_YAML_PATH);
|
||||||
|
const dp = require(DIST_PATH);
|
||||||
|
const cfg = yaml.load(fs.readFileSync(CONFIG_PATH, 'utf8')) || {};
|
||||||
|
const result = dp.configSchema.strict().safeParse(cfg);
|
||||||
|
if (result.success) {
|
||||||
|
out.ok = true;
|
||||||
|
out.keys = Object.keys(cfg).length;
|
||||||
|
} else {
|
||||||
|
out.ok = false;
|
||||||
|
out.errors = (result.error && result.error.issues || []).slice(0, 10)
|
||||||
|
.map(i => ({path: (i.path || []).join('.') || '(root)', msg: i.message}));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
out.mode = 'schema-unavailable';
|
||||||
|
out.error = String(e && e.message || e).slice(0, 200);
|
||||||
|
}
|
||||||
|
console.log('@@' + JSON.stringify(out));
|
||||||
|
""".replace("JS_YAML_PATH", json.dumps(LC_JS_YAML)) \
|
||||||
|
.replace("DIST_PATH", json.dumps(LC_DATA_PROVIDER_DIST)) \
|
||||||
|
.replace("CONFIG_PATH", json.dumps(path))
|
||||||
|
|
||||||
|
if os.path.exists(LC_DATA_PROVIDER_DIST):
|
||||||
|
try:
|
||||||
|
proc = subprocess.run(["node", "-e", node_code], capture_output=True,
|
||||||
|
text=True, timeout=60)
|
||||||
|
for line in (proc.stdout or "").splitlines():
|
||||||
|
if line.startswith("@@"):
|
||||||
|
res = json.loads(line[2:])
|
||||||
|
if res.get("ok"):
|
||||||
|
print(f"config OK (librechat): {res['keys']} top-level "
|
||||||
|
"key(s) accepted by the deployed strict schema",
|
||||||
|
flush=True)
|
||||||
|
sys.exit(0)
|
||||||
|
errs = "; ".join(
|
||||||
|
f"{e['path']}: {e['msg']}" for e in res.get("errors", []))
|
||||||
|
if errs:
|
||||||
|
fail(errs, "rejected by the deployed build's strict "
|
||||||
|
"config schema (configSchema.strict())")
|
||||||
|
fail("(root)", "strict schema rejected the config")
|
||||||
|
# No @@ line: schema path unavailable — fall through to fallback.
|
||||||
|
print("note: deployed schema probe produced no result "
|
||||||
|
f"(stderr: {(proc.stderr or '')[:120]!r})", flush=True)
|
||||||
|
except (OSError, subprocess.TimeoutExpired) as exc:
|
||||||
|
print(f"note: could not run node against the deployed schema "
|
||||||
|
f"({type(exc).__name__})", flush=True)
|
||||||
|
else:
|
||||||
|
print("note: deployed data-provider dist not found; using the static "
|
||||||
|
"fallback allowlist recorded from the deployed build", flush=True)
|
||||||
|
|
||||||
|
# Fallback: static allowlist (still fail-closed).
|
||||||
|
unknown = sorted(set(cfg) - LIBRECHAT_TOP_LEVEL_FALLBACK)
|
||||||
|
if unknown:
|
||||||
|
fail(", ".join(unknown), "unknown top-level key(s) for librechat "
|
||||||
|
f"(fallback allowlist: {', '.join(sorted(LIBRECHAT_TOP_LEVEL_FALLBACK))})")
|
||||||
|
print(f"config OK (librechat, fallback allowlist): {len(cfg)} top-level "
|
||||||
|
"key(s)", flush=True)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
args = sys.argv[1:]
|
||||||
|
if len(args) != 2 or args[0] not in ("litellm", "librechat"):
|
||||||
|
print("usage: validate_config.py <litellm|librechat> <config.yaml>",
|
||||||
|
file=sys.stderr, flush=True)
|
||||||
|
sys.exit(2)
|
||||||
|
if args[0] == "litellm":
|
||||||
|
validate_litellm(args[1])
|
||||||
|
validate_librechat(args[1])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in new issue
Block a user