Skip to content

fix(config): tolerate bare permission words in MIMOCODE_PERMISSION env var - #2248

Open
rekty wants to merge 1 commit into
XiaomiMiMo:mainfrom
rekty:fix/permission-env-bare-word-crash
Open

fix(config): tolerate bare permission words in MIMOCODE_PERMISSION env var#2248
rekty wants to merge 1 commit into
XiaomiMiMo:mainfrom
rekty:fix/permission-env-bare-word-crash

Conversation

@rekty

@rekty rekty commented Aug 25, 2026

Copy link
Copy Markdown

Summary

Wraps JSON.parse(MIMOCODE_PERMISSION) in a try/catch so bare words like allow (a common mistake from setx MIMOCODE_PERMISSION allow) no longer crash every subcommand.

Problem

Setting MIMOCODE_PERMISSION=allow as a bare word (without JSON quotes) crashes MiMoCode at startup on every subcommand with JSON Parse error: Unexpected identifier "allow" — including headless ones like debug and session list. Recovery requires manually editing the Windows registry.

Fix

  1. Tolerate bare words allow, ask, deny → treat as { "*": value } with a warning
  2. Other bare words → clear error message with hint on correct syntax
  3. Valid JSON values → work exactly as before (no behavior change)

Changed: 1 file, +23/−1 (packages/opencode/src/config/config.ts)

Closes #2170

CC @MiMoHardFather @wqymi @yanyihan-xiaomi — please approve CI runs for first-time contributor. 🙏

…v var

The MIMOCODE_PERMISSION environment variable is parsed as JSON at startup.
When set to a bare word like `allow` (a common mistake from `setx
MIMOCODE_PERMISSION allow`), JSON.parse throws and crashes every
subcommand including headless ones.

This change wraps the parse in try/catch and falls back to treating
the bare words 'allow', 'ask', and 'deny' as wildcard permissions
(`{ "*": value }`) with a console warning.  Unrecognized bare words
now produce a clear, actionable error message instead of a raw
SyntaxError.

Closes XiaomiMiMo#2170
@rekty

rekty commented Aug 25, 2026

Copy link
Copy Markdown
Author

Hi @MiMoHardFather @wqymi @yanyihan-xiaomi! This PR fixes a startup crash when MIMOCODE_PERMISSION is set to a bare word. Could you please approve the CI workflow runs? Thank you! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant