ConfigurableParam: reject malformed container fields, drop redundant parseSet#63
Merged
Merged
Conversation
…parseSet
Follow-up hardening on top of the std-container ConfigurableParam support.
1. split() no longer silently drops empty fields. A stray delimiter such as
"[1,,3]" previously parsed to a 2-element vector with no error, and "key:"
collapsed an empty map value away. Both now produce an empty token that is
rejected by parseScalar / the map-syntax check, so malformed configuration
surfaces as an error instead of corrupting element counts. The empty
container case ("[]" / "{}") is still short-circuited by the callers before
split() runs, so well-formed input is unaffected.
2. Removed the redundant parseSet() branch (and the now-unused HasPushBack
concept). Every non-map Container already satisfies SequenceContainer, so the
parseSet dispatch was reached for all sequence and set types and re-parsed the
string into a throwaway std::vector before copying element-by-element.
parseSequence inserts at end(), which std::set / std::unordered_set accept
just as well, so all non-map containers now share a single, single-pass path.
3. Re-enabled cleanup of test_config.root in ConfigurableParam_Container_FileIO_ROOT
(the std::remove was left commented out), restoring test isolation.
Adds regression tests: set/unordered_set/list/deque parsing through the unified
parseSequence path (incl. set de-duplication), and rejection of empty tokens in
both sequence and map parsing.
Note: container parse failures remain non-fatal (logged), matching the existing
scalar setValue behaviour; this commit does not change that contract.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Stacked on top of AliceO2Group#15525 (
cfg/dynamic) — this PR targets that branch, so the diff shown here is only the follow-up changes, not the container support itself.Three follow-up improvements found while reviewing AliceO2Group#15525, all confined to
ContainerParserand its tests:1. Reject malformed container fields instead of silently dropping them
split()discarded empty fields, so a stray delimiter was swallowed:"[1,,3]"parsed to a 2-element vector with no error (element count silently corrupted)."key:"dropped the empty map value.split()now keeps empty tokens, so they are rejected byparseScalar/ the map-syntax check and surface as a parse error. The empty-container case ("[]"/"{}") is still short-circuited by the callers beforesplit()runs, so well-formed input is unaffected.2. Remove the redundant
parseSetbranch (single-pass parsing)Every non-map
Containeralready satisfiesSequenceContainer, so theparseSetdispatch branch was reached for all sequence and set types and re-parsed the string into a throwawaystd::vectorbefore copying element-by-element; the separateelse if constexpr (Container<T>)branch was unreachable.parseSequenceinserts atend(), whichstd::set/std::unordered_setaccept just as well, so all non-map containers now share one single-pass path. The now-unusedHasPushBackconcept is removed.3. Re-enable test cleanup
ConfigurableParam_Container_FileIO_ROOTlefttest_config.rooton disk (thestd::removewas commented out); re-enabled to restore test isolation.Tests
Adds regression coverage:
parseSequencepath (incl. set de-duplication);Note on error severity (intentionally unchanged)
Container parse failures remain non-fatal (logged), which matches the existing scalar
setValuebehaviour (it already swallows scalar parse errors tostd::cerr). This PR does not change that contract — it only stops malformed input from being silently accepted as a different value.Verification: the changed parser logic was extracted into a standalone C++20 program and confirmed to compile (
g++ -std=c++20 -Wall -Wextra) and behave correctly; full build + boost-test runs are left to CI.🤖 Generated with Claude Code