[bug] Startup crash: JSON Parse error: Unexpected identifier "allow" when MIMOCODE_PERMISSION is set as a bare word
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
- 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. - Optionally tolerate the bare words
allow/ask/deny(the only documented action values) when JSON.parse fails. - 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
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.
改动已拆分到独立 PR:PR #2214。