MiMo-Code icon indicating copy to clipboard operation
MiMo-Code copied to clipboard

[bug] Startup crash: JSON Parse error: Unexpected identifier "allow" when MIMOCODE_PERMISSION is set as a bare word

Open cuac333 opened this issue 3 months ago • 2 comments

Environment

  • Windows 11, MiMoCode v0.1.12 (Bun build)
  • Reproduced on every subcommand: mimo, mimo debug config, mimo session list

Symptom

Every mimo invocation crashes at startup with:

JSON Parse error: Unexpected identifier "allow"

and the TUI shows tui bootstrap failed. This happens regardless of config/data state: after wiping all of ~/.config/mimocode, ~/.local/share/mimocode and ~/.cache/mimocode, the exact same crash occurs.

Root cause

The environment variable MIMOCODE_PERMISSION was set (persisted in the Windows registry, HKCU:Environment) to the bare word allow:

setx MIMOCODE_PERMISSION allow

MiMoCode parses this variable as JSON at startup. The documented correct value (see permissions.md: (env) MIMOCODE_PERMISSION='"allow"') is the quoted string "allow". A bare allow is invalid JSON → Unexpected identifier "allow" → crash on every launch.

Because environment variables are snapshotted per-process, the failure also persists in already-open terminals even after fixing the registry value — the only recovery is: delete the registry value and open a fresh terminal.

Suggested fix

  1. Validate the value and surface a clear, actionable error (e.g. "MIMOCODE_PERMISSION must be valid JSON; got bare 'allow' — did you mean "allow"?") instead of a raw JSON Parse error.
  2. Optionally tolerate the bare words allow / ask / deny (the only documented action values) when JSON.parse fails.
  3. A single bad env var should not fatally break every subcommand including headless ones (debug, session list, providers) — a warning would be enough.

Crash backtrace: SyntaxError: JSON Parse error: Unexpected identifier "allow" at <parse> (:0) at parse (unknown) at <anonymous> (B:/~BUN/root/chunk-3egw8k9j.js:536:5321) ... at processTicksAndRejections (native:7:39) fatal

cuac333 avatar Aug 19 '26 21:08 cuac333

I have prepared a focused fix for this issue.

The change accepts bare allow/ask/deny values for MIMOCODE_PERMISSION and replaces raw JSON parse failures with actionable configuration errors. I also added focused tests. I will open a PR covering this fix together with the related non-Git undo feedback fix in #2209.

wutongyuonce avatar Aug 23 '26 09:08 wutongyuonce

改动已拆分到独立 PR:PR #2214。

wutongyuonce avatar Aug 23 '26 09:08 wutongyuonce