Skip to content

[Bug]: Title: Gateway regenerates service-env file on every restart, wiping Telegram bot tokens (and other secrets) with placeholder values #98107

Description

@1Wanker

Bug type

Crash (process/app exits or hangs)

Beta release blocker

No

Summary

Environment: macOS 26.5.1 (arm64), OpenClaw 2026.6.10, LaunchAgent service install, npm-managed CLI/gateway
. Every time the gateway restarts (openclaw gateway restart, launchctl kickstart, or after openclaw update), the file ~/.openclaw/service-env/ai.openclaw.gateway.env is regenerated and resets TELEGRAM_DEFAULT_BOTTOKEN and TELEGRAM_HERMES_BOTTOKEN to their placeholder values (your-real-telegram-default-token-here), even though OPENCLAW_SERVICE_MANAGED_ENV_KEYS only lists OPENROUTER_API_KEY. This causes the Telegram channel to fail immediately on every restart with Call to 'deleteWebhook' failed! (404: Not Found), since the bot token is invalid I ran openclaw secrets configure to map channels.telegram.accounts.default.botToken and hermes-default.botToken to source: env references (TELEGRAM_DEFAULT_BOTTOKEN / TELEGRAM_HERMES_BOTTOKEN), expecting this to persist the values, but the underlying service-env file is still wiped on restart regardless.

Steps to reproduce

1.	Install OpenClaw gateway as a macOS LaunchAgent (openclaw gateway install) with Telegram channel configured for two accounts, each using channels.telegram.accounts.<id>.botToken with source: env.
2.	Add real bot tokens to ~/.openclaw/service-env/ai.openclaw.gateway.env manually (e.g. export TELEGRAM_DEFAULT_BOTTOKEN='<real_token>').
3.	Confirm the gateway starts and Telegram channel shows OK via openclaw status.
4.	Run openclaw gateway restart (or trigger any service restart, including via openclaw update).
5.	Inspect ~/.openclaw/service-env/ai.openclaw.gateway.env again.
6. Actual: TELEGRAM_DEFAULT_BOTTOKEN and TELEGRAM_HERMES_BOTTOKEN are reset to placeholder strings (your-real-telegram-default-token-here), even though OPENCLAW_SERVICE_MANAGED_ENV_KEYS in that same file only lists OPENROUTER_API_KEY as managed. Telegram then fails to start with Call to 'deleteWebhook' failed! (404: Not Found) because the token is invalid.
7. Running openclaw secrets configure to map the tokens as source: env references does not fix this — the underlying service-env regeneration on restart still wipes the values regardless.

Expected behavior

xpected: Either these tokens should be included in OPENCLAW_SERVICE_MANAGED_ENV_KEYS so they’re preserved across regeneration, or openclaw secrets configure should actually persist the secret value somewhere durable (e.g. Keychain) rather than only updating the config reference.

Actual behavior

Actual: TELEGRAM_DEFAULT_BOTTOKEN and TELEGRAM_HERMES_BOTTOKEN are reset to placeholder strings (your-real-telegram-default-token-here), even though OPENCLAW_SERVICE_MANAGED_ENV_KEYS in that same file only lists OPENROUTER_API_KEY as managed. Telegram then fails to start with Call to 'deleteWebhook' failed! (404: Not Found) because the token is invalid.

OpenClaw version

2026.6.10

Operating system

mac 26.5.1

Install method

mac app

Model

openrouter/ gemini 2.5 flash

Provider / routing chain

openclaw

Additional provider/model setup details

No response

Logs

Screenshots, recordings, and evidence

No response

Impact and severity

No response

Additional information

Current workaround: Maintaining tokens in a separate file and manually re-injecting them into service-env before every restart.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.bugSomething isn't workingclawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for 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.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions