Skip to content

macOS update/reinstall can overwrite generated gateway env wrapper and make status misleading for secret-provider setups #90518

Closed

Description

@TurboTheTurtle

Summary

After updating OpenClaw to 2026.6.1 on macOS, a LaunchAgent-managed gateway using a secret-provider-backed environment broke because the generated gateway env wrapper was regenerated during reinstall/repair.

This is not a request to add Infisical-specific support. OpenClaw already has the right first-class mechanism via:

  • openclaw gateway install --wrapper <path>
  • OPENCLAW_WRAPPER

The issue is that update/install/doctor/status flows do not make it obvious when a user has modified a generated wrapper, or when CLI diagnostics are running outside the same secret-provider context as the installed gateway service.

Environment

  • macOS
  • LaunchAgent-managed OpenClaw gateway
  • OpenClaw 2026.6.1 (2e08f0f)
  • Gateway health endpoint: 127.0.0.1:18789
  • Secrets provided through an external wrapper, not directly present in the interactive shell

What Happened

After running the update/reinstall flow, openclaw gateway install --force regenerated:

~/.openclaw/service-env/ai.openclaw.gateway-env-wrapper.sh

back to the plain generated wrapper behavior:

source <env-file>
exec "$@"

That overwrote local wrapper behavior that had been calling a stable secret-provider executor:

~/.openclaw/service-env/openclaw-infisical-env-exec.py

As a result:

  • openclaw status printed many missing env-var warnings even though secrets had been migrated to the secret provider.
  • The gateway entered a crash/spawn loop until the service wrapper/env setup was repaired.
  • The interactive CLI path also remained misleading because /opt/homebrew/bin/openclaw invoked Node directly, so openclaw status bypassed the same secret-provider context used by the LaunchAgent service.

Why This Was Confusing

Generated *-env-wrapper.sh files appear to be overwritten by design, which is reasonable.

However, it is easy for operators to miss that modifying the generated wrapper is fragile. After reinstall/repair, the service and CLI can also disagree:

  • The installed gateway service may have access to secrets through a wrapper.
  • The interactive CLI process may not.
  • openclaw status then reports missing env vars even when the intended service path has been repaired or is otherwise configured differently.

Requested Behavior

Consider one or more of the following:

  1. During gateway install --force, update, or doctor repair, detect when the generated env wrapper contains non-generated custom behavior and warn before overwriting it.

  2. If overwriting is intentional, explicitly recommend moving custom behavior to a stable wrapper passed through:

openclaw gateway install --wrapper <path>

or:

OPENCLAW_WRAPPER=<path>
  1. Make openclaw status diagnostics clearer when required secrets may be available only through the installed gateway/service wrapper, but not through the current interactive CLI process.

  2. Have doctor surface a warning when the CLI/status environment differs materially from the installed service wrapper environment.

Related Auth Profile Migration Issue

During the same update, agent runs also hit Codex app-server auth-profile validation failures around legacy profile IDs matching:

openai-codex:*

while validation expected canonical IDs like:

openai:*

This may be a separate migration-timing issue, but it appeared during the same update/repair window. It may be useful for doctor to flag legacy openai-codex:* auth-profile IDs before app-server validation rejects them, or to make that migration timing clearer.

Local Repair / Validation

After repair, the local setup was changed to:

  • Use a stable wrapper outside the generated wrapper path.
  • Invoke the local CLI through the same secret-provider wrapper context.
  • Avoid storing secret values in generated files.

Validation after repair:

  • Gateway health live on 127.0.0.1:18789
  • openclaw --version returns 2026.6.1 (2e08f0f)
  • openclaw status --timeout 15000 no longer reports missing env-var diagnostics
  • openclaw status --deep --timeout 30000 reports Discord, iMessage, Slack, and Telegram OK

Activity

  1. clawsweeper commented on Jun 5, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 21, 2026, 7:50 AM ET / 11:50 UTC.

    Summary
    Keep open: current main and the latest release still rewrite the generated macOS LaunchAgent env wrapper without detecting local custom behavior, and the open linked PR is the active closing fix path.

    Reproducibility: yes. The reporter supplied an isolated macOS LaunchAgent repro, and current main still has the unconditional generated-wrapper write path; I did not run a fresh live macOS repro in this read-only review.

    Root-cause cluster
    Relationship: canonical
    Canonical: #90518
    Summary: This issue is the canonical report for generated macOS LaunchAgent env-wrapper overwrite and misleading status diagnostics; the linked open PR is the candidate fix.

    Members:

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

    Next step
    No new repair lane should be queued because the open linked PR already owns the implementation path.

    Review details

    Best possible solution:

    Review and land #90537 if it remains acceptable, keeping --wrapper and OPENCLAW_WRAPPER as the durable operator path and tracking any auth-profile migration concern separately.

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

    Yes. The reporter supplied an isolated macOS LaunchAgent repro, and current main still has the unconditional generated-wrapper write path; I did not run a fresh live macOS repro in this read-only review.

    Is this the best way to solve the issue?

    Yes. The linked PR's warning at the launchd wrapper write site plus status-context hint is narrower than provider-specific support or a new configuration surface.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The related legacy openai-codex auth-profile migration note is not proven to share this wrapper overwrite root cause and should stay separate unless it still reproduces.
    • The central bug remains present on current main and v2026.6.9 until the linked PR lands or maintainers choose another fix.

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

    Label changes

    Label justifications:

    • P2: This is a confirmed macOS gateway install/status reliability bug with a clear workaround and an active focused fix path.
    • impact:auth-provider: The failure involves secrets available through the installed service wrapper context but missing from the interactive CLI/status environment.
    • impact:crash-loop: When the generated wrapper is overwritten, a LaunchAgent-managed gateway can repeatedly crash or respawn until wrapper setup is repaired.
    Evidence reviewed

    What I checked:

    • Reporter repro: The issue comment includes an isolated macOS LaunchAgent repro showing gateway install --force rewrote a customized generated wrapper back to stock content and removed the custom marker.
    • Current main wrapper rewrite path: Current main writes the generated LaunchAgent env wrapper directly with no existing-content check or overwrite warning. (src/daemon/launchd.ts:214, d1cbe29f3d52)
    • Current status diagnostics lack wrapper context: Current main prints redacted secret diagnostics before the main report, but does not add a hint when the CLI process is outside the installed service wrapper context. (src/commands/status.command.ts:244, d1cbe29f3d52)
    • Supported durable wrapper seam: Gateway docs already document --wrapper and OPENCLAW_WRAPPER as the persistent managed-service wrapper path for forced reinstalls, updates, and doctor repairs. Public docs: docs/cli/gateway.md. (docs/cli/gateway.md:461, d1cbe29f3d52)
    • Latest release still lacks the fix: The latest release tag v2026.6.9 points at c645ec4 and contains the same direct generated-wrapper write path. (src/daemon/launchd.ts:213, c645ec4555c0)
    • Open linked fix PR: GitHub reports Warn on generated wrapper overwrites and status diagnostics #90537 as an open closing reference for this issue; the PR body targets the wrapper overwrite warning and status diagnostics. (7386fe85f4a0)

    Likely related people:

    • steipete: Authored the earlier persistent gateway service wrapper support that defines the supported durable wrapper path this issue relies on. (role: feature owner / wrapper seam contributor; confidence: high; commits: 9f9bd41f40df, 975d40d47483, 976ea3ff5091; files: src/cli/daemon-cli/install.ts, src/commands/daemon-install-helpers.ts, src/daemon/program-args.ts)
    • vincentkoc: Current blame for the launchd wrapper write path, gateway wrapper docs, daemon install wrapper handling, and status secret diagnostics points to a recent main rewrite, with adjacent update cutover work in the same service area. (role: recent area contributor; confidence: medium; commits: c9758bf2a090, a15797ad1129, c645ec4555c0; files: src/daemon/launchd.ts, src/commands/daemon-install-helpers.ts, src/commands/status.command.ts)
    • TurboTheTurtle: Authored the open focused fix PR and has current-main launchd update-job history adjacent to macOS service maintenance. (role: current fix author / adjacent contributor; confidence: medium; commits: 49e5091f180e, 7386fe85f4a0; files: src/daemon/launchd.ts, src/cli/update-cli/update-command.ts)
    • Bek: Recent macOS launchd stop/restart lifecycle work touched the managed-service restart path adjacent to wrapper regeneration behavior. (role: recent launchd lifecycle contributor; confidence: low; commits: 69974530987c; files: src/daemon/launchd.ts)
    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.
  2. added
    P2Normal backlog priority with limited blast radius.
    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 5, 2026
  3. TurboTheTurtle commented on Jun 5, 2026

    @TurboTheTurtle
    ContributorAuthor

    Added a live macOS LaunchAgent repro for the generated-wrapper overwrite path. This used an isolated throwaway profile/state dir, not my real gateway service.

    Environment:

    • macOS LaunchAgent install path
    • OpenClaw 2026.6.2 (8deff20) from current local main build
    • Isolated profile: issue90518repro
    • Throwaway LaunchAgent label: ai.openclaw.issue90518repro
    • Throwaway state dir: /tmp/openclaw-90518-repro.UvAeAo
    • Throwaway port: 19899
    • Cleanup confirmed the throwaway plist was removed afterward

    Repro steps and observed output:

    == first install ==
    {
      "action": "install",
      "ok": true,
      "result": "installed",
      "service": {
        "label": "LaunchAgent",
        "loaded": true,
        "loadedText": "loaded",
        "notLoadedText": "not loaded"
      }
    }
    Wrapper exists after first install: yes
    Wrapper SHA after first install: 08abc38cdc39727ed8580697adac8004bbac7ee7647c9d3d3c96a7fe403cf75a
    Wrapper content after first install:
    #!/bin/sh
    set -eu
    env_file="$1"
    shift
    if [ -f "$env_file" ]; then
      . "$env_file"
    fi
    exec "$@"
    

    Then I simulated operator custom behavior inside the generated wrapper path:

    == simulate operator custom behavior inside generated wrapper ==
    Custom marker present before force reinstall: yes
    Wrapper SHA after customization: 649d6c0776510d626894c872a210384f89c9fa6bcd020a08bb32789349361642
    Wrapper content after customization:
    #!/bin/sh
    set -eu
    env_file="$1"
    shift
    if [ -f "$env_file" ]; then
      . "$env_file"
    fi
    echo "custom-secret-provider-marker" >/tmp/openclaw-90518-wrapper-marker
    exec "$@"
    

    Then I forced a reinstall of the same isolated LaunchAgent:

    == force reinstall ==
    {
      "action": "install",
      "ok": true,
      "result": "installed",
      "service": {
        "label": "LaunchAgent",
        "loaded": true,
        "loadedText": "loaded",
        "notLoadedText": "not loaded"
      }
    }
    Custom marker present after force reinstall: no
    Wrapper SHA after force reinstall: 08abc38cdc39727ed8580697adac8004bbac7ee7647c9d3d3c96a7fe403cf75a
    Wrapper content after force reinstall:
    #!/bin/sh
    set -eu
    env_file="$1"
    shift
    if [ -f "$env_file" ]; then
      . "$env_file"
    fi
    exec "$@"
    
    Generated env file exists: yes
    LaunchAgent plist exists: yes
    

    Cleanup confirmation:

    == cleanup ==
    {
      "action": "uninstall",
      "ok": true,
      "result": "uninstalled",
      "service": {
        "label": "LaunchAgent",
        "loaded": false,
        "loadedText": "loaded",
        "notLoadedText": "not loaded"
      }
    }
    LaunchAgent plist exists after cleanup: no
    

    Expected: if OpenClaw is about to overwrite a generated macOS env wrapper that contains non-generated custom behavior, it should warn and point the operator to the persistent openclaw gateway install --wrapper <path> / OPENCLAW_WRAPPER mechanism.

    Actual: openclaw gateway install --force silently rewrote the generated wrapper back to the stock wrapper and removed the custom behavior.

    This repro intentionally uses a harmless marker command instead of any real secret provider. It demonstrates the same failure mode as a local secret-provider exec wrapper being placed inside the generated *-env-wrapper.sh file and then being silently removed by reinstall/update/repair.

    @clawsweeper re-review

  4. clawsweeper commented on Jun 5, 2026

    @clawsweeper
    Contributor

    🦞🧹
    ClawSweeper re-review requested.

    I asked ClawSweeper to review this item again.
    Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
    Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

    Re-review progress:

  5. added
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    and removed
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    on Jun 5, 2026
  6. added
    clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    and removed
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    on Jun 15, 2026
  7. locked as resolved and limited conversation to collaborators on Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.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: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions