fix(config): parse bracket-delimited list values in config set - #37460
fix(config): parse bracket-delimited list values in config set#37460liuhao1024 wants to merge 1 commit into
Conversation
When the user runs `hermes config set enabled '[icarus]'`, the value was stored as a literal YAML string instead of a list. This adds YAML parsing for values matching `[...] ` syntax, converting them to proper lists. Fixes NousResearch#37455
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Nice fix: hermes config set now parses [bracket-delimited] values as YAML lists instead of storing them as literal strings. Uses YAML safe_load to parse the bracket content, falling back to string on parse failure. +6 tests covering single/multi/empty/quoted items and invalid input.
✅ Looks Good
- +61/-0 lines with 6 comprehensive tests
- Clean fallback behavior on invalid YAML
- Enables config values like
hermes config set enabled '[icarus, zeus]' - Well-documented with regression reference (#37455)
Reviewed by Hermes Agent
teknium1
left a comment
There was a problem hiding this comment.
Thanks for identifying a real config set type-coercion gap. Current main still only coerces booleans and numeric scalars in hermes_cli/config.py:8157-8167, while plugin loading requires plugins.enabled to be a list in hermes_cli/plugins.py:263-266.
Problems
- The invalid-YAML regression test added at
tests/hermes_cli/test_set_config_value.py:280uses[not: valid: yaml, which has no closing]. It therefore never enters the new bracket-delimited parsing branch and does not test its fallback behavior. - GitHub currently reports this PR as merge-conflicting. The current target has moved to
hermes_cli/config.py:8100-8186and contains newer managed-scope, config-load, alias, and env-bridge behavior that must be retained during salvage.
Suggested changes
- Transplant the coercion into the current scalar-coercion block at
hermes_cli/config.py:8157. - Replace the fallback fixture with malformed YAML that still ends in
], then assert it persists as the original string.
Automated hermes-sweeper review.
| reloaded = yaml.safe_load(_read_config(_isolated_hermes_home)) | ||
| assert reloaded["enabled"] == ["icarus", "zeus"] | ||
|
|
||
| def test_non_list_bracket_string_kept_as_string(self, _isolated_hermes_home): |
There was a problem hiding this comment.
This input lacks the closing ], so it never reaches the new startswith('[') and endswith(']') parser branch. Please use malformed YAML that still ends in ] so this test exercises the fallback.
|
Resolved via PR #88163 (merged) — |
What does this PR do?
Fixes
hermes config setso that bracket-delimited values like[icarus]are parsed as YAML lists instead of being stored as literal strings. Previously,hermes config set enabled '[icarus]'wroteenabled: '[icarus]'(a string), silently breaking plugin loading.Related Issue
Fixes #37455
Type of Change
Changes Made
hermes_cli/config.py: Added YAML list parsing for values matching[...]syntax inset_config_value(). When the value starts with[and ends with], it is parsed viayaml.safe_load(); if the result is a list, it replaces the raw string. Invalid YAML falls back to the original string behavior.tests/hermes_cli/test_set_config_value.py: AddedTestBracketListValuesclass with 6 regression tests: single-element list, multi-element list, quoted items, invalid YAML fallback, empty list, and nested key list value.How to Test
hermes config set enabled '[icarus]'and verifyconfig.yamlcontainsenabled:\n- icarus(a YAML list, not a string)hermes config set enabled '[icarus, zeus]'and verify both items appear as a listpython3 -m pytest tests/hermes_cli/test_set_config_value.py -v— all 38 tests should passChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/hermes_cli/test_set_config_value.py -qand all 38 tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
hermes_cli/config.py:set_config_value(called fromconfig_commandCLI handler)config setvalue parsing; no impact on config reading, migration, or other commandshermes config set#33145 (bare-string home_channel handling); both extendset_config_valuetype coercion