Skip to content

[Bug]: Config file wiped on Gateway restart #40410

@zenenznze

Description

@zenenznze

Bug Description

When OpenClaw Gateway restarts (e.g., after system reboot), the configuration file ~/.openclaw/openclaw.json is being overwritten with a nearly empty file, causing complete loss of configuration.

Environment

  • OS: Linux (Ubuntu/Debian based)
  • Node: 24.x
  • OpenClaw: v2026.3.7

Reproduction Steps

  1. Have a working OpenClaw configuration with ~470 lines (~11KB)
  2. Restart the system or restart OpenClaw Gateway
  3. After Gateway starts, check ~/.openclaw/openclaw.json
  4. The file is reduced to ~10 lines (~400 bytes)
  5. Gateway fails to start with error: Gateway start blocked: set gateway.mode=local (current: unset)

Actual Behavior

The configuration file is completely wiped on Gateway restart. The audit log shows config size dropped from 11653 bytes to 421 bytes, with 28 configuration paths lost.

Impact

  • Severity: Critical (P0)
  • Gateway becomes non-functional after restart
  • All configuration including channel credentials, API keys, cron jobs, agent settings are lost

Suggested Fix

  1. Add config integrity check before Gateway starts (verify key fields exist)
  2. Add pre-write backup (backup before any config modification)
  3. Add config operation logging (log read/merge/validate operations, not just write)
  4. Add config size change alert (>20% change should trigger warning)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions