Skip to content

gateway install --force drops MINIMAX_API_KEY from service-env despite managed keys list #90277

Closed

Description

@Kvikkulf

Summary

On macOS (LaunchAgent), openclaw gateway install --force regenerates ~/.openclaw/service-env/ai.openclaw.gateway.env but does not export MINIMAX_API_KEY, even though:

  1. MINIMAX_API_KEY is present and non-empty in ~/.openclaw/.env
  2. MINIMAX_API_KEY appears in OPENCLAW_SERVICE_MANAGED_ENV_KEYS
  3. Other managed keys (e.g. MINIMAX_WEBSEARCH_API_KEY, DEEPSEEK_API_KEY, OPENROUTER_API_KEY) are exported correctly

The gateway then crashes immediately on startup:

SecretRefResolutionError: Environment variable "MINIMAX_API_KEY" is missing or empty.

Environment

  • OpenClaw version: 2026.6.1 (2e08f0f)
  • OS: macOS 26.5 (arm64)
  • Node: 22.22.3 (via nvm); LaunchAgent uses /opt/homebrew/bin/node
  • Service: LaunchAgent ai.openclaw.gateway.plist, port 18789

Config context

models.providers.minimax-openai.apiKey uses a proper env SecretRef:

"apiKey": {
  "source": "env",
  "provider": "default",
  "id": "MINIMAX_API_KEY"
}

(MINIMAX_WEBSEARCH_API_KEY in the minimax plugin uses the same SecretRef shape and does get exported.)

Reproduction

# Confirm key exists in .env
grep '^MINIMAX_API_KEY=' ~/.openclaw/.env   # non-empty

# Regenerate service env
openclaw gateway install --force

# MINIMAX_API_KEY missing from exports:
grep '^export MINIMAX_API_KEY=' ~/.openclaw/service-env/ai.openclaw.gateway.env || echo MISSING

# Gateway fails to start
openclaw gateway restart
openclaw gateway status --deep
# Runtime: stopped, Connectivity probe: failed, ECONNREFUSED :18789

Latest stability bundle message:

Startup failed: required secrets are unavailable.
SecretRefResolutionError: Environment variable "MINIMAX_API_KEY" is missing or empty.

Impact

  • LaunchAgent enters a crash loop; agent integrations lose connectivity
  • Watchdog recovery that only runs install --force re-triggers the bug on every attempt
  • Manual workaround: append export MINIMAX_API_KEY='...' to service-env after every install --force

Suggested fix

Ensure gateway install exports every key listed in OPENCLAW_SERVICE_MANAGED_ENV_KEYS when a non-empty value exists in ~/.openclaw/.env, with no special-casing that skips MINIMAX_API_KEY.

Activity

  1. clawsweeper commented on Jun 4, 2026

    @clawsweeper
    Contributor

    Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

    Close: current main contains the generic placeholder-filtering fix and regression coverage for the reported macOS LaunchAgent service-env loss, and the fix was released in v2026.6.5.

    I found the merged PR that appears to have closed this: #90488: fix service env placeholder collection.

    So I’m closing this as already implemented rather than keeping a duplicate issue open.

    Review details

    Best possible solution:

    Keep the merged generic placeholder-filtering behavior and close this report as fixed, with any future service-env regressions filed as fresh issues with current-version proof.

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

    Yes for the original shipped failure: the issue gives exact macOS LaunchAgent steps, and the merged regression test exercises the same service-env planning path with an unresolved MINIMAX_API_KEY self-reference. On current main, that path now preserves the .env value instead of reproducing the failure.

    Is this the best way to solve the issue?

    Yes. The merged generic config-env placeholder filter is the narrow maintainable fix because it avoids MiniMax-specific special casing and prevents unresolved placeholder strings from masking durable .env secrets.

    Security review:

    Security review: This is a non-PR issue cleanup; no proposed patch security review is needed here.

    AGENTS.md: found and applied where relevant.

    What I checked:

    • Repository policy read and applied: Root AGENTS.md was read fully; its source/history/release proof and config/env compatibility review guidance affected this cleanup decision. (AGENTS.md:28, 8682d0701b27)
    • Current source filters unresolved placeholders: Current collectConfigEnvVarsByTarget skips values containing unresolved env-var references in both env.vars and top-level config env keys, preventing ${MINIMAX_API_KEY} from masking the state-dir .env value. (src/config/config-env-vars.ts:34, 8682d0701b27)
    • Current install-plan regression covers the reported shape: The current daemon install helper test writes MINIMAX_API_KEY to the state-dir .env, configures an unresolved self-reference plus a MiniMax env SecretRef, plans a Darwin install, and asserts the key is exported with OPENCLAW_SERVICE_MANAGED_ENV_KEYS. (src/commands/daemon-install-helpers.test.ts:1183, 8682d0701b27)
    • Current gateway install path uses the fixed collector before render policy: Gateway install planning collects state-dir .env, config env, SecretRef env, exec passEnv, and auth-profile env sources before formatting managed keys and applying the LaunchAgent render policy. (src/commands/daemon-install-helpers.ts:529, 8682d0701b27)
    • Fix provenance from merged PR: Merged PR fix service env placeholder collection #90488 produced commit 7ac1eeb; git show shows it added the placeholder filtering and the focused regression tests, while its parent lacked the placeholder skip. (src/config/config-env-vars.ts:34, 7ac1eeb12220)
    • Release provenance: GitHub release v2026.6.5 was published on 2026-06-09 and its release notes say service env planning skips unresolved placeholders that would mask state-dir .env values, referencing this issue and the merged fix PR. (5181e4f7c82b)

    Likely related people:

    • sallyom: Authored the merged service-env placeholder fix and was assigned on this issue before the fix PR landed. (role: fix author and assigned follow-up owner; confidence: high; commits: 7ac1eeb12220; files: src/config/config-env-vars.ts, src/config/config.env-vars.test.ts, src/commands/daemon-install-helpers.test.ts)
    • steipete: The prior public ClawSweeper review traced durable service-env helper and render-policy history in the same gateway install path to this contributor; the local shallow checkout limited deeper blame beyond that public history. (role: recent area contributor; confidence: medium; commits: 838644b989f1, c15282062f04, ba9fb4d994d6; files: src/commands/daemon-install-helpers.ts, src/daemon/service-env-render-policy.ts, src/daemon/service-managed-env.ts)
    • WarrenJones: The related merged reinstall-preservation PR modified the same gateway install helper and tests around preserving or dropping service environment values during forced install. (role: adjacent reinstall env preservation contributor; confidence: medium; commits: 40c5edb5b1ca; files: src/commands/daemon-install-helpers.ts, src/commands/daemon-install-helpers.test.ts)

    Codex review notes: model internal, reasoning high; reviewed against 8682d0701b27; fix evidence: merged PR #90488, release v2026.6.5, commit 7ac1eeb12220.

  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:crash-loopCrash, hang, restart loop, or process-level availability failure.
    impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    on Jun 4, 2026
  3. self-assigned this
    on Jun 4, 2026
  4. locked as resolved and limited conversation to collaborators on Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions