Repository navigation
fix: read hand-written settings files that start with a byte-order mark - #67
Merged
Merged
Conversation
…rk (refs #22) Root cause: every reader of a file a person writes by hand called std::fs::read_to_string and parsed the text as it came. Windows PowerShell 5.1's `Set-Content -Encoding utf8` and some editors start a UTF-8 file with U+FEFF; str::trim keeps it and serde_json/toml refuse it. So: - a plugin manifest was refused with "`name` is missing" (found by hand under #22); - a custom command's front matter was not recognised, so its allowed-tools were silently not applied and the command ran with every tool; - admin settings, MCP server files, the project's permission settings, managed settings, guards, contracts and lifecycle files were refused or ignored; the first keybinding, the first verification check and the first spec/PRD heading were dropped. Only subagents.rs stripped the mark. Now one reader, text::read_authored, drops a leading mark and keeps read_to_string's errors, and every hand-authored reader uses it. A mark inside the text is kept. Tests: one per consequential reader (plugin install, command allowed-tools, admin, MCP, project deny rule, keybinding, verification check) plus the reader itself; all 8 fail with the strip disabled.
7 of 13 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.
Found while trying #22 by hand on Windows.
The bug
A UTF-8 file can start with an invisible byte-order mark (U+FEFF). Windows PowerShell 5.1's
Set-Content -Encoding utf8writes one, and so do some editors. incode read hand-written files withstd::fs::read_to_stringand parsed them as they came, so:incode plugin addrefused the plugin with "nameis missing".allowed-toolswas silently not applied, and a "Read only" command could use every tool.admin.json,mcp.json/.mcp.json, the project's.incode/settings.json(permission rules),managed.toml,guards.json,contracts.jsonandlifecycle.jsonwere refused or ignored.VERIFICATION.mdcheck and the first spec/PRD heading.Only the agent-definition reader (
subagents.rs) handled the mark.The fix
One reader,
text::read_authored, drops a leading mark and keepsread_to_string's errors. Every reader of a hand-written file now uses it. A mark in the middle of a file is kept.Verified
239 187 191), and installed the same plugin without it (the control).allowed-tools, admin, MCP, a project deny rule, a keybinding, a verification check, the reader itself). All 8 fail with the fix disabled and pass with it.-D warningsclean;cargo test2335 lib + 59 bin passed.