fix(config): tolerate bare permission words in MIMOCODE_PERMISSION env var - #2248
Open
rekty wants to merge 1 commit into
Open
fix(config): tolerate bare permission words in MIMOCODE_PERMISSION env var#2248rekty wants to merge 1 commit into
rekty wants to merge 1 commit into
Conversation
…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
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! 🙏 |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wraps
JSON.parse(MIMOCODE_PERMISSION)in a try/catch so bare words likeallow(a common mistake fromsetx MIMOCODE_PERMISSION allow) no longer crash every subcommand.Problem
Setting
MIMOCODE_PERMISSION=allowas a bare word (without JSON quotes) crashes MiMoCode at startup on every subcommand withJSON Parse error: Unexpected identifier "allow"— including headless ones likedebugandsession list. Recovery requires manually editing the Windows registry.Fix
allow,ask,deny→ treat as{ "*": value }with a warningChanged: 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. 🙏