fix(config): parse structured list/dict values in hermes config set (consolidates 8-PR cluster) - #88163
Merged
Merged
Conversation
Fold the list/mapping parser INSIDE the existing string-typed-value coercion guard (the `not isinstance(_default_value_for_key(key), str)` block from e4ea0a0) instead of running it unconditionally, so a genuinely string-typed setting whose value merely starts with '[' or '{' is left untouched while non-string keys get JSON/YAML flow literals parsed to real lists/dicts. Update website/docs/user-guide/configuring-models.md: the `config set only writes scalar values` note is no longer accurate; document the list/mapping support with a quoted example. Fixes #40545 #50168
…s with a conservative trigger Consolidation follow-up on top of #59182's cherry-picked base: - Add _looks_structured_value(): triggers a yaml.safe_load structured parse only when the value starts with '[' / '{' or spans multiple lines with YAML list-item ('- x') or mapping-entry ('key: v') shaped lines. Deliberately avoids the over-broad leading '-' trigger from #88066 so '-5' and '--flag' stay strings. - Stays folded INSIDE the string-typed-key guard: keys whose DEFAULT_CONFIG type is str (e.g. approvals.mode) are never coerced. - Tests: multi-line YAML list/dict, string-typed key given '[x]' and '-5' stays string, dash-prefixed scalars stay strings, plain multi-line prose stays a string, load_config round-trip. Sabotage-verified: 7 of the suite's tests fail on main without the fix.
Contributor
૮ >ﻌ< ა ci reviewran on 0e1fac7 — fix(config): extend structured-value parsing to multi-line Y
|
This was referenced Aug 17, 2026
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.
hermes config setnow parses structured list/dict values (JSON flow literals and multi-line YAML blocks) into real YAML structures instead of writing them verbatim as quoted strings — while keeping string-typed keys (e.g.approvals.mode) exempt from all coercion.Changes
yaml.safe_loadstructured-parse branch INSIDE the existing string-typed-key guard inset_config_value, triggered on values starting with[/{. Warns to stderr and keeps the string when the value looks structured but doesn't parse to a list/mapping. Includes tests + docs update._looks_structured_value()helper extends the trigger to multi-line YAML block values (- itemlines orkey: valuelines), sohermes config set custom_providers '<multi-line yaml>'stores a real list of mappings. The trigger is deliberately conservative: single-line dash-prefixed scalars (-5,--flag) never reach the YAML parser (avoids the over-broad leading--trigger from fix(config): parse YAML list/dict values in set_config_value #88066). If the parse yields a plain scalar, the original string is kept._default_value_for_key) and the mapping-overwrite guard (hermes config set <section> <value> silently destroys the whole mapping (model/terminal/gateway), reports success, and leaves model: as a bare string the loader can't repair #74995 lineage) — nested-key writes still go through_set_nested.Validation
pytest tests/hermes_cli/test_config_set_list_values.py tests/hermes_cli/test_set_config_value.py -o addopts="" -q(py3.11, isolatedHERMES_HOME)config.py)ruff checkon touched filesapprovals.mode '[off]'and'-5'stay strings (tested)load_configas a real list (tested)Cluster
This PR consolidates an 8-PR duplicate cluster, all addressing "config set stores structured values as strings":
yaml.safe_loadyaml.safe_load-trigger was over-broad)Thanks to all eight contributors — @liuhao1024 reported/fixed this earliest; #59182 was picked as the base because it was the only variant already folded inside the string-typed-key guard.
Infographic