fix(config): parse list literals in config set; tolerate string-typed scan roots - #82227
Closed
gtmacdonald wants to merge 1 commit into
Closed
fix(config): parse list literals in config set; tolerate string-typed scan roots#82227gtmacdonald wants to merge 1 commit into
gtmacdonald wants to merge 1 commit into
Conversation
…typed scan roots
Two sides of one bug class: `hermes config set desktop.repo_scan_roots
'["~/src"]'` stored the literal as a quoted STRING, and the desktop
repo-discovery policy loader's isinstance-list guard silently discarded
it — falling back to roots=[] (scan all of $HOME). The discovered_repos
cache kept refilling with stale entries and the Projects sidebar showed
long-dead repos no matter how often the cache was purged.
- hermes_cli/config.py set_config_value: values starting with [ or {
for non-string-typed keys are YAML/JSON-parsed and stored as real
collections. String-typed keys (display.skin etc.) keep literal text;
malformed literals stay strings.
- tui_gateway/server.py _repo_discovery_policy: new _coerce_scan_path_list
parses a string-typed list literal already sitting in user config (with
a warning), accepts a bare path as a one-element list, and only then
falls back to defaults — so existing broken configs heal instead of
silently scanning $HOME.
Contributor
|
Resolved via PR #88163 (merged) — |
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.
Symptom
hermes config set desktop.repo_scan_roots '["~/src"]'stores the value as a quoted string, not a list:The desktop repo-discovery policy loader (
_repo_discovery_policyintui_gateway/server.py) guards withisinstance(roots, list), so the string fails the check and silently falls back to the defaultroots: []— which means "scan all of $HOME". Thediscovered_reposcache then keeps refilling with every git checkout under the user's home (old coursework, backups, vendored trees), and stale entries keep resurfacing in the desktop Projects sidebar no matter how often the cache is purged. No warning is emitted anywhere; the persisted policy inprojects.db(repo_discovery_policy→"roots":[]) is the only visible evidence.Hit this in the wild: configured scan root ignored, 40+ junk repos resurfacing in the picker after every purge.
Fix (both sides of the bug class)
Write side —
hermes_cli/config.pyset_config_value: values starting with[/{for non-string-typed keys are parsed withfast_safe_loadand stored as real YAML collections. String-typed keys (e.g.display.skin) keep literal text — the existing enum-preservation contract is untouched. Malformed literals stay strings (historical behavior).Read side —
tui_gateway/server.py_repo_discovery_policy: new_coerce_scan_path_listhelper heals a string-typed list literal already sitting in user config (logs a warning telling the user to re-save), accepts a bare path string as a one-element list, and only falls back to defaults for genuinely unusable values. Existing broken configs written by older CLI versions stop silently scanning $HOME.Tests
9 new tests, all asserting behavior contracts (no snapshots):
tests/hermes_cli/test_set_config_value.py— list literal → real YAML list; empty list; string-typed default keeps literal text; malformed literal stays a stringtests/tui_gateway/test_projects_rpc.py— string literal parsed; bare path → one-element list; real list unchanged; garbage falls back to default; excludes get the same treatmentBranch is cut from current
upstream/main(73997c4).