fix(config): parse JSON list/dict values in config set - #60558
Conversation
Duplicate of #40546 — same fix (JSON |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused fix. The underlying issue is still present on current main: hermes_cli/config.py:8268-8279 performs scalar coercion only, then writes JSON-looking input unchanged.
Problems
- The proposed parser at
hermes_cli/config.py:8042was authored before current main added the declared-string preservation guard inhermes_cli/config.py:8264-8278(e4ea0a0ed7). Salvaging the old hunk verbatim would conflict with that later invariant. - The PR diff changes no tests. Current coverage in
tests/hermes_cli/test_set_config_value.pyincludes string-default behavior, but no JSON list/dict round-trip regression forconfig set.
Suggested changes
- Integrate JSON list/dict parsing into the current non-string coercion branch, retaining
_default_value_for_key()protection for declared string leaves. - Add round-trip coverage for
terminal.env_passthroughas a JSON array, a JSON mapping, malformed JSON fallback, and the string-default invariant.
Automated hermes-sweeper review.
| stripped = value.strip() | ||
| if stripped.startswith(('{', '[')): | ||
| try: | ||
| parsed = json.loads(stripped) |
There was a problem hiding this comment.
Current main now preserves values for keys whose DEFAULT_CONFIG leaf is a string (e4ea0a0ed7, now hermes_cli/config.py:8264-8278). Please integrate this structured parse under that non-string guard when salvaging, so the newer string-value invariant remains intact.
b089cf2 to
72e64da
Compare
hermes config set stores list values like '["A","B"]' as
quoted YAML scalar strings instead of YAML sequences because
set_config_value() only coerces booleans, ints, and floats.
Add JSON parsing for values starting with '{' or '[' so list
and dict values are serialized as proper YAML sequences/mappings.
Also loosen the value parameter type from str to Any since it
can now hold list/dict values after JSON parsing.
Closes NousResearch#60551
72e64da to
6bd780a
Compare
… file feat(bench): add tool_search_livetest2 benchmark script for deferred-tool scenarios
|
Resolved via PR #88163 (merged) — |
Summary
Fixes #60551:
hermes config setstores list values like'["A","B"]'as quoted YAML scalar strings instead of YAML sequences.Root Cause
set_config_value()inhermes_cli/config.pycoerces values to bool/int/float but has no JSON parsing step for list and dict shapes. When a user runs:The value stays as a string, and YAML serialization writes it as a quoted scalar:
Fix
Add JSON parsing for values starting with
{or[after the existing type coercion. If parse succeeds and result is a dict or list, use the parsed value — YAML serialization then writes it as a proper sequence/mapping.Test Plan
["A","B"]as scalar string- A\n- BChange
1 file, +10 lines:
hermes_cli/config.py