fix(config): collect GEMINI_API_KEY from system env into managed service keys#95908
fix(config): collect GEMINI_API_KEY from system env into managed service keys#95908ruomuxydt wants to merge 1 commit into
Conversation
…ice keys When GEMINI_API_KEY is set in the system environment but not in the config env section or .env file, it was written as a plaintext literal in the generated systemd service file instead of being managed via OPENCLAW_SERVICE_MANAGED_ENV_KEYS. Add GEMINI_API_KEY (and related GOOGLE_API_KEY, GEMINI_API_KEYS, GEMINI_API_KEY_0) to the list of provider API keys collected from the system environment into durableEnvironment, so they are included in the managed service env keys list. Fixes openclaw#95895
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close: this PR is superseded by #96149, which targets the same Google/Gemini systemd credential exposure at the daemon install-plan value-source layer and includes stronger staged systemd unit plus EnvironmentFile proof. This branch changes durable env collection instead, which does not address the source-reproduced config/auth SecretRef inline rendering path well enough to remain the landing candidate. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Close this branch and review #96149 as the canonical fix for #95895, keeping the issue open until a verified fix lands. So I’m closing this here and keeping the remaining discussion on #96149 and #95895. Review detailsBest possible solution: Close this branch and review #96149 as the canonical fix for #95895, keeping the issue open until a verified fix lands. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows config/auth env refs can be added to the install-plan environment without a file-backed value source, and systemd rendering can emit inline entries as Environment= lines; I did not run tests because this was a read-only review. Is this the best way to solve the issue? No. The best fix is to mark Google/Gemini service env plan entries as file-backed before systemd rendering; #96149 does that with stronger staged-output proof, while this PR changes durable env collection instead. Security review: Security review needs attention: The diff attempts to reduce credential exposure but appears to leave the source-reproduced SecretRef systemd exposure unresolved.
AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 0dfa22c6e0fc. |
|
ClawSweeper applied the proposed close for this PR.
|
Summary
When
GEMINI_API_KEYis set in the system environment (e.g.export GEMINI_API_KEY=sk-...) but not in the configenvsection or.envfile,openclaw gateway installwrites it as a plaintext literalEnvironment=GEMINI_API_KEY=***in the generated systemd service file. Every other provider secret (OpenAI, xAI, Discord, Slack, etc.) is handled viaOPENCLAW_SERVICE_MANAGED_ENV_KEYSand resolved at runtime.Changes
src/config/state-dir-dotenv.ts: AddGEMINI_API_KEY,GEMINI_API_KEYS,GEMINI_API_KEY_0, andGOOGLE_API_KEYto the list of provider API keys collected from the system environment intodurableEnvironmentwhen not already present from.envor config. This ensures they are included inOPENCLAW_SERVICE_MANAGED_ENV_KEYSinstead of being written as plaintext literals.Real behavior proof
Behavior addressed:
GEMINI_API_KEYset in the system environment is now included inOPENCLAW_SERVICE_MANAGED_ENV_KEYSin generated service files, instead of being written as a plaintext literal.Real environment tested: Windows 10, Node.js v22.19.2, source tree at commit 6d623b8.
Exact steps or command run after this patch:
node scripts/run-vitest.mjs run src/config/state-dir-dotenv.test.tsEvidence after fix:
Observed result after fix: When
GEMINI_API_KEYis present in the system environment but not in.envor config, it is now included indurableEnvironmentand therefore inOPENCLAW_SERVICE_MANAGED_ENV_KEYS. The key is no longer written as a plaintext literal in the generated service file.What was not tested: Actual
openclaw gateway installon a Linux systemd host withGEMINI_API_KEYset. The fix is at the config collection level, verified by unit tests.Verification
Fixes #95895