ui-server config: two comments promise nothing below createApp reads process.env, but a dozen call sites do
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, typescript
- Ambito
- backend, developer-experience
Direzione di ricerca
Leggi packages/ui-server/src/app.ts attorno al commento su CreateAppOptions.config e alle chiamate a githubToolsTokenSource(), poi confronta l’intestazione di packages/ui-server/src/config/env.ts con DYNAMIC_ENV_READS. Aggiorna i commenti per descrivere le letture rimanenti dell’ambiente di processo e condividi una sola closure della sorgente del token GitHub tools tra i relativi consumatori. Controlla le suite GitHub tools e della route dei dettagli GitHub indicate nella PR, insieme ai controlli elencati per l’ambiente e i report API.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Context
CreateAppOptions.config promises that createApp resolves the environment once, "here at the edge — nothing deeper in the package touches the ambient environment", so that two differently configured apps can run in one process and tests can vary configuration without mutating process.env (packages/ui-server/src/app.ts:234-240). The header of config/env.ts repeats it: every consumer "never touches process.env itself" (packages/ui-server/src/config/env.ts:13-16).
That is not what the code does. These helpers default to process.env and are called without an environment argument below the edge:
subprocessEnv()(config/env.ts:1486-1492), which filtersprocess.envfor a child process at call time:app.ts:510(twice) and:870,attachments/extract.ts:89,brain/application.ts:200,brain/client.ts:204,:212,:326,routes/brain.ts:317,schedules/service.ts:139,storage/removal-facts.ts:12,storage/removal.ts:235.- Credential and key sources:
referenceCredentialValues()(app.ts:556),apifyTokenSource()(app.ts:820),githubToolsTokenSource()(app.ts:843and again at:1231),resolveWebSearchEnv()(app.ts:868,routes/web-search.ts:146). - Three lazy
createModelPricing(resolveStandalonePricingConfig())fallbacks (activity/store.ts:458,ws/session-catalog.ts:217,ws/session-catalog-writes.ts:141). maintenanceDataRoot()(config/env.ts:1594-1596), read in the maintenance child's entry (brain/maintenance-entry.ts:41).
The effect: createApp({ config: resolveServerConfig(customEnv) }) applies only part of customEnv. Two apps in one process, or two tests, cannot differ in child environment, GitHub or Apify credentials, reference credentials or web-search keys without changing process.env. A reader who trusts either comment will write such a test and get the ambient values.
Part of this is documented as intended. DYNAMIC_ENV_READS lists subprocessEnv as a call-time read (config/env.ts:1572-1591), docs/supported-inputs.md:637 documents subprocessEnv(audience, extra, extraNames) as a supported input, and child environments are a privilege boundary (docs/decisions/hardening.md, ruling 4). The closed epic #1343 fixed the exec wrapper and listed subprocessEnv() as out of scope, and #2784 repeats that exclusion. So the two comments are the part that is wrong.
Decision (2026-11-27, delegated orchestrator choice; reviewer marked it the clear preferred option): correct the two comments to what the code does, and build the GitHub tools token source once per app. Nobody has a use case today for two apps in one process with different credentials or child environments. Rejected: resolving every read once at boot, which turns a documented call-time read at a privilege boundary into a boot-time snapshot and adds fields to the documented ServerConfig; and threading only the credential, web-search and pricing sources through ServerConfig, which adds contract surface and threads through createApp ahead of #2784 with no caller asking for it.
Related: #2784 (splits createApp and edits the same file; whichever lands second rebases). #4822 edits other comments in config/env.ts; whichever lands second rebases.
Scope
- The doc comment on
CreateAppOptions.config(app.ts:234-240) says what passingconfigcovers and what it does not:createAppresolvesServerConfigonce, and these are still read from the process environment whateverconfigholds: child-process environments (subprocessEnv, at each spawn), the reference, Apify and GitHub-tools credentials, the web-search provider keys, and the standalone pricing fallback. It says that two apps in one process share those. - The header comment of
config/env.ts(:13-16) says the same in one or two sentences and points atDYNAMIC_ENV_READSfor the call-time reads. createAppcallsgithubToolsTokenSource()once and passes the one closure to bothcreateGithubToolsHostandcreateGithubDetails(app.ts:843,:1231).
Out of scope
- Threading any environment-derived value through
ServerConfig, and any newServerConfigfield. subprocessEnv,BRAIN_UI_SUBPROCESS_ENV_EXTRA, the audience allowlists, and theDYNAMIC_ENV_READSentries: unchanged.ENV_VARS,docs/supported-inputs.mdand the generated environment documentation: no variable is added, removed or redocumented.- Restructuring
createApp(#2784). - The exec wrapper (
ServerConfig.exec), already resolved at the edge (app.ts:381-388). maintenanceDataRoot(): it runs in the maintenance child process, which has noServerConfig.- The other comments in
config/env.tsthat no longer sit on their declarations (#4822).
Acceptance criteria
-
git grep -n "nothing deeper in the package touches the ambient environment" -- packages/ui-server/srcreturns nothing, and the header ofconfig/env.tsno longer says that consumers never touchprocess.env. - The
CreateAppOptions.configcomment names each group of remaining ambient reads listed in Scope, and each name it uses is an exported function that exists (subprocessEnv,referenceCredentialValues,apifyTokenSource,githubToolsTokenSource,resolveWebSearchEnv,resolveStandalonePricingConfig). The PR lists, for each group, one call site that proves the comment true. -
git grep -n "githubToolsTokenSource(" -- packages/ui-server/src/app.tsshows one call. - The existing GitHub tools and GitHub detail route suites pass with no edit to their assertions (the PR names them).
-
subprocessEnv,DYNAMIC_ENV_READSandENV_VARSare byte-identical, and the env-access gate and the env-parity gate pass. -
api-report/ui-server.txtis byte-identical.
Verification
bun run test packages/ui-server/tests/env.test.ts
bun run test packages/ui-server
NODE_OPTIONS=--max-old-space-size=6144 bun run typecheck
bun run lint
bun run api-report
bun run check:pr --base origin/main
Contract impact
- This touches the integration contract, so it needs the
contractlabel, aCONTRACT:commit prefix, and the doc updated in the same commit. - This changes a published package's behaviour, so it needs a changeset.
Two comments change and one token closure is shared by its two consumers; both closures read the same variable at boot today, so no request, credential or child environment differs.
Found by a repository audit on 2026-11-26 (main 87b96b10c); independently reviewed before filing.
- Lingua principale
- TypeScript
- Stelle
- 5
- Fork
- 0
- Merge medio
- 8h 3m
- PR unite (30g)
- 606
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di schlessera/brain-kit
-
ui-sdk: the turnId doc comment tells client authors echoing is optional, which a rev 3 host refusesApertaagent-ready area: ui-sdk priority: p3 type: docs
Difficoltà 1/5 1-3 ore Idoneità per principianti 86/100
schlessera/brain-kit#4824 ·
I maintainer di solito rispondono entro 1 giorno
-
ui-react: the recordings tray and the associate dialog import each other for two label helpersApertaagent-ready area: ui-react blocked priority: p3 type: refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
schlessera/brain-kit#4819 ·
I maintainer di solito rispondono entro 1 giorno
-
jobs: every command writes on open, so a read fails with "database is locked" during a long writeApertaagent-ready area: modules priority: p2 type: fix
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
schlessera/brain-kit#4809 ·
I maintainer di solito rispondono entro 1 giorno
-
agent-ready area: ui-server priority: p3 type: fix
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
schlessera/brain-kit#4807 ·
I maintainer di solito rispondono entro 1 giorno
-
agent-ready area: ui-server priority: p2 type: refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
schlessera/brain-kit#4806 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di schlessera/brain-kit
Issue simili
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:auth-provider issue-rating: 🦞 diamond lobster no-stale P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
openclaw/openclaw#206303 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
eliasstravik/herdr-projects#1604 · 1 commento ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
golang-malawi/qatarina#502 ·
I maintainer di solito rispondono entro 2 giorni