fix(uninstall): match quoted keys/values and inline comments - #98
Merged
Conversation
The line-based matcher only recognized the exact unquoted forms setup.sh
writes, so a hand-edited config using single/double quotes ("aws-builder":,
- "builder", provider: 'builder') or inline # comments would leave a dangling
provider/toolset/model reference on uninstall.
Add _strip_inline_comment, _unquote, _mapping_key and _provider_value helpers
and route the provider-key, list-item and model.provider matches through them.
Adds 3 regression tests.
_unquote stripped whitespace inside quoted YAML scalars, so a distinct value like " builder " was normalized to builder and wrongly removed. Preserve the scalar contents after removing only the quote delimiters. Adds a regression test asserting quoted whitespace scalars are untouched.
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
Follow-up to #97. Hardens
scripts/uninstall.shto also match quoted keys/values and inline comments on the builder entries, so a hand-editedconfig.yamlcan't leave a dangling reference on uninstall.Problem
The line-based matcher (introduced in #97 to preserve comments) only recognized the exact unquoted forms
setup.sh/Hermes actually write. A user who hand-edited their config with quoting or inline comments would leave behind:"aws-builder":/'builder':(quoted provider key)- "builder"/- 'builder'(quoted enabled/toolset list item)provider: 'builder'(single-quoted model.provider)aws-builder: # note/- builder # note/provider: builder # note(inline comments)These are false-negatives (fail to remove, never corrupt) — the worst case is a visible dangling reference — but the original
yaml.safe_load-based cleanup handled all of them, so this closes that robustness gap.Change
Four small helpers, and the three matchers now route through them:
_strip_inline_comment(s)— drop a trailing whitespace-preceded#comment (quote-aware)._unquote(s)— strip matching single/double quotes._mapping_key(s)— unquoted key of akey: ...line (provider block detection)._provider_value(s)— unquoted value afterprovider:(model.provider detection)._is_builder_itemnow strips comments + quotes before comparing.Adds 3 regression tests (quoted provider keys/values, quoted list items, inline comments). No behavior change for the unquoted, comment-free forms.
Tests
tests/test_uninstall.py: 15 tests (3 new) — all pass.ruffclean (3 local-only N999 from the checkout dir name),ruff formatclean.Greptile Summary
The uninstall cleanup now handles quoted scalar whitespace and inline comments, but valid YAML double-quoted escape sequences are still missed. A Builder configuration written as
"bui\x6cder"remains installed because the script does not recognize that YAML resolves it tobuilder.Confidence Score: 4/5
Not safe to merge until uninstall recognizes YAML-escaped Builder identifiers.
The reproduced cleanup failure leaves plugin-owned provider, toolset, plugin-list, and model-provider configuration behind when equivalent YAML escape notation is used.
Files Needing Attention: scripts/uninstall.sh
What T-Rex did
Comments Outside Diff (3)
General comment
model.providervalue written as" builder "is semantically distinct frombuilder, but uninstall removes it. The isolated end-to-end run removed the unrelated provider block, all quoted managed-list entries, and the model provider line._unquoteinscripts/uninstall.sh:92-96first trims syntax-adjacent whitespace and then calls.strip()ons[1:-1]at line 95. Callers at lines 104, 112, and 120 therefore receivebuilderfor the distinct quoted scalar" builder ", causing the removal predicates at lines 154, 174, and 187 to match..strip()from quoted-scalar handling (returns[1:-1]) while retaining only the outer trim needed to locate quote delimiters. Add regression cases for quoted keys, list items, andmodel.providervalues containing significant edge whitespace.scripts/uninstall.sh, line 51-54 (link)Valid double-quoted YAML scalars such as
"bui\x6cder"decode tobuilder, but the raw-text presence check reports Builder absent and exits before cleanup. Even if that guard is removed,_unquoteonly strips delimiters rather than decoding double-quoted YAML escapes, so provider keys, managed list entries, andmodel.providervalues using equivalent escaped scalars do not match the Builder slugs. Uninstall leaves the plugin configuration behind.Artifacts
Validation script for literal and YAML-escaped builder uninstall cases
Literal builder uninstall control log
YAML-escaped builder uninstall failure log
General comment
"bui\x6cder"values is semantically equivalent tobuilder. The executed escaped case showed PyYAML readingbuilderfor the provider key, enabled/plugin toolset lists, and model provider, while uninstall reported that builder was absent and left every item unchanged.builder(scripts/uninstall.sh:51-54), and_unquoteonly removes quote delimiters without decoding YAML double-quoted escape sequences (scripts/uninstall.sh:92-97). Consequently, path and value comparisons never see the decoded slug.Reviews (2): Last reviewed commit: "fix(uninstall): preserve inner whitespac..." | Re-trigger Greptile