Repository navigation
Fail on YAML parse errors and quote policy values that need it - #198
Merged
github-actions[bot] merged 2 commits intoOct 15, 2026
Merged
Conversation
This was referenced Oct 11, 2026
arasHi87
marked this pull request as ready for review
October 11, 2026 15:10
ReadYml() ignored the result of yaml_parser_parse(). After a parse error
libyaml only returns empty events, never the mapping or stream end the
loop waits for, so a malformed policy (e.g. "note: a: b") made
hex_translate spin at 100% CPU while holding the hex_config apply lock.
processLayer() now stops on a parse error or an empty event and
ReadYml() logs the problem with line and column and returns -1, which
every caller already handles.
WriteYml() wrote leaf values as plain scalars, so a value such as
"a: b", "x # y" or "#general" came out as invalid or truncated yaml.
A value is now single-quoted only when a plain scalar would not read
back as the same string (": ", " #", a leading indicator, leading or
trailing blanks), and double-quoted with escapes when it holds control
characters. Empty values, booleans, numbers and other plain values, as
well as values the caller already quoted, are written as before.
Refs: bigstack-oss/cubecos#1956, bigstack-oss/cubecos#1780
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JCTPUxQtqcY5nG3XLQCspk
Signed-off-by: arashi.li <[email protected]>
…sing Tunings::enabled was left uninitialised, and HexYmlParseBool() keeps the value when "enabled" is missing from tuning1_0.yml, so translate_tuning wrote or skipped the tunings depending on stack contents and the compiler. Default it to true, as TuningPolicy::clear() does. Refs: bigstack-oss/cubecos#1956 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JCTPUxQtqcY5nG3XLQCspk Signed-off-by: arashi.li <[email protected]>
Eandalf-Bigstack
force-pushed
the
arashi.li/1956-yml-parse-error-and-quoting
branch
from
October 15, 2026 04:03
6c53488 to
e38c54d
Compare
Eandalf-Bigstack
approved these changes
Oct 15, 2026
github-actions
Bot
deleted the
arashi.li/1956-yml-parse-error-and-quoting
branch
October 15, 2026 04:06
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.
What type of PR is this?
/kind bug
What this PR does / why we need it
yml_utilcould hang the CLI and lose values.processLayer()ignored the result ofyaml_parser_parse(). After a parse error libyaml returns empty events forever, so a policy value such asnote: a: bmadehex_translatespin andhex_cli … configurenever returned.processLayernow returns -1 on a parse error orYAML_NO_EVENT, andReadYmllogsFailed to parse policy file <file>: <problem> at line L, column Cand returns -1. Every caller already handled< 0.writeNode()wrote leaf values raw, soa: b,x # y, a leading#(Slack#general, cubecos#1780), leading or trailing blanks and similar values became invalid or truncated YAML. Such values are now single-quoted, or double-quoted with escapes when they hold control characters. Values that round-tripped before (booleans, numbers including-1, hosts, URLs, already-quoted values) are written byte for byte as before.Tunings.enabledwas uninitialised; it now defaults totrue, asTuningPolicy::clear()does, so a missing key no longer yields stack garbage.Which issue(s) this PR fixes
Refs bigstack-oss/cubecos#1956
Refs bigstack-oss/cubecos#1780
bigstack-oss/cubecos#2050 bumps this submodule and closes both tickets; it depends on this PR.
QA
QA-Status: Not needed
Test evidence
New
test_api_03(parse errors and a write/read round trip of 20+ awkward values) passes;test_api_01/02still pass (CentOS Stream 9 container, libyaml 0.2.5, 2026-10-11). On develop'syml_util.ctest_api_03spins untiltimeout(rc 124). Blind verification on a single-node 3.2.0 lab cluster, 2026-10-11: FIXED for #1956 and #1780.yml_util tests: this branch, develop, and reader-fix-only
Blind verification: verdict excerpt
add receiver email ... "a: b"applies and does not hanga: bround-tripslistshowsNote: a: b, the raw line isnote: 'a: b', settings.txt hasemails.0.note = a: b#round-tripsNote: # hash, rawnote: '# hash'hex_translate translatereturned rc=1 in 0.010 s; log:Failed to parse policy file …/alert_setting1_0.yml: mapping values are not allowed in this context at line 17, column 14#channelround-tripslistshows Channel#rt694-v1956, rawchannel: '#rt694-v1956', the UI/API returnname: "#rt694-v1956"/etc/policiesended identical to the snapshot.Special notes for your reviewer
Note
processLayer/ReadYmlinsrc/hex_sdk_library/yml_util/yml_util.c, thenscalarStyle/writeScalar;tests/test_api_03.clists every value checked.policy_notify_trigger.cppquotes the alert_respmatchitself.-,?and:are quoted only when followed by a blank, so negative numbers stay numbers.yml_util.cis inlibhex_sdk.a, so hex_translate, hex_cli, hex_firsttime and hex_config pick it up. A malformed file now fails cleanly instead of spinning or returning a partial tree.