Skip to content

fix(install): manage config-secretref env refs via OPENCLAW_SERVICE_MANAGED_ENV_KEYS#96065

Merged
obviyus merged 3 commits into
openclaw:mainfrom
Darren2030:fix/secretref-managed-env-keys
Jul 1, 2026
Merged

fix(install): manage config-secretref env refs via OPENCLAW_SERVICE_MANAGED_ENV_KEYS#96065
obviyus merged 3 commits into
openclaw:mainfrom
Darren2030:fix/secretref-managed-env-keys

Conversation

@Darren2030

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #95895 / #96059. When a provider API key such as GEMINI_API_KEY is configured via a config SecretRef (e.g. under models.providers.google.apiKey), openclaw gateway install was writing the key as a plaintext literal in the generated service file. PR #96059 covered auth-profile env refs; this PR covers the config SecretRef source.

Changes

  • src/commands/daemon-install-helpers.ts: include config-secretref env refs when computing OPENCLAW_SERVICE_MANAGED_ENV_KEYS.
  • src/commands/daemon-install-helpers.test.ts: update the config SecretRef assertion and add a GEMINI_API_KEY regression test.
  • scripts/repro/issue-95895-config-secretref-managed-env-keys.mts: standalone reproduction script.

Real behavior proof

  • Behavior addressed: config-secretref GEMINI_API_KEY no longer appears as a plaintext literal; it is listed in OPENCLAW_SERVICE_MANAGED_ENV_KEYS.
  • Real environment tested: Linux, Node 24.13, source tree at current main.
  • Exact steps:
    • pnpm build
    • node --import tsx scripts/repro/issue-95895-config-secretref-managed-env-keys.mts
  • Evidence after fix:
    OPENCLAW_SERVICE_MANAGED_ENV_KEYS=GEMINI_API_KEY
    GEMINI_API_KEY inline=(not inline - good)
    PASS: Config-secretref GEMINI_API_KEY is managed, not written as plaintext.
    
  • Observed result after fix: plan.environment.GEMINI_API_KEY is undefined; plan.environment.OPENCLAW_SERVICE_MANAGED_ENV_KEYS contains GEMINI_API_KEY.
  • What was not tested: Actual systemd service file rendering.

Verification

  • pnpm test src/commands/daemon-install-helpers.test.ts --run — 44 passed
  • node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/commands/daemon-install-helpers.ts src/commands/daemon-install-helpers.test.ts — passed
  • node --import tsx scripts/repro/issue-95895-config-secretref-managed-env-keys.mts — PASS

AI-assisted: yes.

@clawsweeper

clawsweeper Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 1, 2026, 4:57 PM ET / 20:57 UTC.

Summary
The PR changes gateway install planning so config SecretRef environment values are included in managed service env metadata and forwarded through service install callers.

PR surface: Source +39, Tests +133. Total +172 across 9 files.

Reproducibility: yes. Source inspection shows current main can collect config SecretRef env values as inline service env entries while managed-key computation omits that source, and systemd renders inline values unless value-source metadata marks them file-backed.

Review metrics: 2 noteworthy metrics.

  • Managed SecretRef Render Policy: 1 render policy changed; 2 install callers forward metadata. Config SecretRef service-env ownership controls both credential exposure and runtime delivery across install and repair paths.
  • Current Type Gate: 2 TypeScript errors. The PR head cannot merge while its added fixtures fail the repository type gate.

Stored data model
Persistent data-model change detected: migration/backfill/repair: src/cli/daemon-cli/start-repair.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #95895
Summary: This PR is a candidate fix for the canonical plaintext Google/Gemini systemd service credential issue and partially overlaps the macOS service-env token preservation report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦪 silver shellfish
Patch quality: 🧂 unranked krab
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Fix the two current check-test-types fixture errors.
  • Update the PR body with redacted current-head proof showing staged systemd output without inline secrets, EnvironmentFile delivery, and mode 0600.
  • [P1] Add macOS LaunchAgent restart/update proof for config SecretRef preservation or explicitly narrow that scenario out of scope.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR body has terminal-output proof, but it is stale for the latest head because it references a deleted repro script and does not show current-head staged service output after the force-push. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] The PR changes generic config SecretRef service-env ownership, so existing installs may see different secret persistence/rendering behavior across install, repair, and restart paths.
  • [P1] The current PR body proof still references a deleted repro script and does not show current-head staged systemd output, generated 0600 EnvironmentFile delivery, or macOS LaunchAgent restart/update preservation.
  • [P1] The latest head has a failing check-test-types job in the added tests, so the branch is not merge-ready even before the remaining proof and upgrade-safety review.

Maintainer options:

  1. Fix Type Gate And Current Proof (recommended)
    Require the branch to pass check-test-types and include redacted current-head systemd plus macOS LaunchAgent service proof before merge.
  2. Accept Generic SecretRef Management
    Maintainers can explicitly accept that all config SecretRef env refs become service-managed across install and repair surfaces.
  3. Narrow Or Replace The Branch
    If the generic policy is too broad, pause this PR and replace it with a narrower file-backed fix for the canonical provider credential exposure path.

Next step before merge

  • [P1] The remaining blockers are contributor-supplied real behavior proof plus maintainer acceptance of the broad SecretRef service-env policy; automation should not substitute for that proof or product decision.

Security
Cleared: No supply-chain or new code-execution concern was found, but the credential rendering boundary remains upgrade-sensitive and needs proof before merge.

Review findings

  • [P2] Add the required provider baseUrl fixture — src/commands/daemon-install-helpers.test.ts:487-490
  • [P2] Use a typed Telegram SecretRef fixture — src/commands/daemon-install-helpers.test.ts:1281-1285
Review details

Best possible solution:

Fix the typed fixtures, update current-head real service proof, and have maintainers accept the generic config SecretRef managed-env policy or narrow the branch to the canonical credential exposure path.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection shows current main can collect config SecretRef env values as inline service env entries while managed-key computation omits that source, and systemd renders inline values unless value-source metadata marks them file-backed.

Is this the best way to solve the issue?

Partly. Value-source metadata is the right owner boundary for systemd rendering, but this branch is not the best mergeable solution until the typed fixtures compile, current-head real behavior proof is added, and maintainers accept the broader policy.

Full review comments:

  • [P2] Add the required provider baseUrl fixture — src/commands/daemon-install-helpers.test.ts:487-490
    check-test-types fails on current head because this added provider config is missing the required baseUrl field. Add a valid base URL or use an existing typed provider fixture helper so the branch can pass the type gate.
    Confidence: 0.97
  • [P2] Use a typed Telegram SecretRef fixture — src/commands/daemon-install-helpers.test.ts:1281-1285
    check-test-types also fails because this added fixture assigns a SecretRef object where the TypeScript botToken config type is currently string. Use the repository's existing as unknown as OpenClawConfig SecretRef fixture pattern or another typed helper so the test compiles.
    Confidence: 0.95

Overall correctness: patch is incorrect
Overall confidence: 0.93

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 44e88f550b69.

Label changes

Label justifications:

  • P1: The PR targets plaintext credential exposure in generated gateway service files and can affect real provider/channel authentication flows.
  • merge-risk: 🚨 compatibility: Merging changes how existing config SecretRef env values are persisted and rendered during gateway service install or repair.
  • merge-risk: 🚨 auth-provider: The affected values include provider and channel credentials such as Gemini API keys and Telegram bot tokens.
  • merge-risk: 🚨 security-boundary: The diff changes whether secrets are written inline, file-backed, or preserved across managed service regeneration.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body has terminal-output proof, but it is stale for the latest head because it references a deleted repro script and does not show current-head staged service output after the force-push. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +39, Tests +133. Total +172 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 6 111 72 +39
Tests 3 136 3 +133
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 247 75 +172

What I checked:

  • Root policy applied: Root AGENTS.md treats config/env, provider/auth, setup/startup, and service fallback behavior as compatibility-sensitive review surfaces, which applies to this daemon install change. (AGENTS.md:35, 44e88f550b69)
  • Current main behavior: Current main collects config SecretRef env values into the install plan but computes OPENCLAW_SERVICE_MANAGED_ENV_KEYS only from durableEnvironment, so config SecretRef values are not managed by that list on main. (src/commands/daemon-install-helpers.ts:571, 44e88f550b69)
  • Systemd render contract: Current main systemd staging renders inline environment values unless value-source metadata marks them file-backed, so service-env value sources are the right boundary for avoiding inline secret rendering. (src/daemon/systemd.ts:272, 44e88f550b69)
  • PR head implementation: The latest PR head adds configSecretRefEnvironment to managed-key computation and passes it to the render policy, which marks config SecretRefs as file-backed on Linux and inline on other platforms. (src/daemon/service-env-render-policy.ts:68, af0cf4ee653a)
  • Current-head CI failure: The current check-test-types job fails with TS2741 at src/commands/daemon-install-helpers.test.ts:487 and TS2322 at line 1281. (src/commands/daemon-install-helpers.test.ts:487, af0cf4ee653a)
  • Provider type contract: ModelProviderConfig requires baseUrl, matching the failing added OpenAI provider fixture at the PR head. (src/config/types.models.ts:210, 44e88f550b69)

Likely related people:

  • steipete: Path history shows multiple daemon install, managed service env, and service-env planning commits on the central helper and service-env files. (role: recent area contributor; confidence: high; commits: 4eb3d1fae941, 97d2d40fb75b, 2b01bcf6c805; files: src/commands/daemon-install-helpers.ts, src/daemon/service-env-render-policy.ts, src/daemon/service-managed-env.ts)
  • sallyom: Recent merged SecretRef provider integration work touched the same config/auth SecretRef service-env collection boundary. (role: SecretRef integration contributor; confidence: medium; commits: 6037a7466079; files: src/commands/daemon-install-helpers.ts)
  • hclsys: Prior systemd work preserved env-file secrets on re-stage, directly adjacent to the file-backed EnvironmentFile contract used by this PR. (role: systemd env-file contributor; confidence: medium; commits: f8f881f63fab; files: src/commands/daemon-install-helpers.ts, src/daemon/systemd.ts, src/daemon/service-managed-env.ts)
  • vincentkoc: Recent path history includes systemd and LaunchAgent service behavior work in the same daemon runtime surface. (role: daemon/systemd adjacent contributor; confidence: medium; commits: 64785823d093, b258c3fc6578, d7c173b69456; files: src/daemon/systemd.ts, src/commands/daemon-install-helpers.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 23, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime and removed scripts Repository scripts labels Jul 1, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 1, 2026
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: M and removed size: S labels Jul 1, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 1, 2026
@obviyus
obviyus force-pushed the fix/secretref-managed-env-keys branch from f4e9414 to af0cf4e Compare July 1, 2026 20:51
@obviyus
obviyus merged commit e798655 into openclaw:main Jul 1, 2026
94 of 95 checks passed
@obviyus

obviyus commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Landed via squash onto main.

  • Scoped tests: env CI=true OPENCLAW_VITEST_MAX_WORKERS=1 corepack pnpm test src/commands/daemon-install-helpers.test.ts src/daemon/systemd.test.ts src/wizard/setup.finalize.test.ts src/cli/daemon-cli/lifecycle-core.test.ts src/cli/daemon-cli/lifecycle.test.ts -- --run
  • Changelog: release-owned, not updated
  • Land commit: af0cf4e
  • Merge commit: e798655

Thanks @Darren2030!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 2, 2026
* fix(install): manage config-secretref env refs via OPENCLAW_SERVICE_MANAGED_ENV_KEYS
* fix(install): preserve config secret refs in launchd env
* fix(install): preserve secretref env render sources

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
chenyangjun-xy pushed a commit to chenyangjun-xy/openclaw that referenced this pull request Jul 3, 2026
* fix(install): manage config-secretref env refs via OPENCLAW_SERVICE_MANAGED_ENV_KEYS
* fix(install): preserve config secret refs in launchd env
* fix(install): preserve secretref env render sources

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
sheyanmin pushed a commit to sheyanmin/openclaw that referenced this pull request Jul 8, 2026
* fix(install): manage config-secretref env refs via OPENCLAW_SERVICE_MANAGED_ENV_KEYS
* fix(install): preserve config secret refs in launchd env
* fix(install): preserve secretref env render sources

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
wheakerd pushed a commit to wheakerd/clawdbot that referenced this pull request Jul 15, 2026
* fix(install): manage config-secretref env refs via OPENCLAW_SERVICE_MANAGED_ENV_KEYS
* fix(install): preserve config secret refs in launchd env
* fix(install): preserve secretref env render sources

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit e798655)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations gateway Gateway runtime merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants