feat(xceadmin): validate percent-based limit values are in [0.0, 1.0] (bug-1833)
Adds an if/then JSON Schema (draft 2020-12) conditional constraint to limits.schema.json's Limit definition: when percent is true, value must be a number in [0.0, 1.0]. This is the class of authoring mistake bug-1831/bug-1832 fixed manually (night_mem_pct: value: 50 instead of 0.5) -- now caught automatically at real `xceadmin config build` time (the actual cluster.bin generation path deploy-ha.sh uses), not merely by a unit test. Empirically verified against the real jsonschema library this repo uses: a violation surfaces with the exact same file/json_pointer/ constraint contract validate_yaml()'s existing ValidationError already provides, so zero changes were needed to its error-reporting code. While implementing this, the new constraint caught an identical pre-existing defect in xceadmin's own checked-in "full" golden test fixture (fixtures/full/configs/limits.yaml, night_mem_pct: value: 50) -- fixed the same way, and regenerated the checked-in expected.bin golden artifact to match the corrected input. Added 3 tests to test_validation.py: reject an out-of-range percent value, accept an in-range one, and confirm a non-percent value is never range-checked regardless of magnitude. Build gotcha discovered and documented (cerebrum.md): this repo has two copies of every bundled schema -- src/configs/schema/ (canonical) and src/xceadmin/src/xcecommon/schema_files/json/ (a gitignored local mirror meson-build.sh always overwrites from the canonical copy on every build). Only the canonical copy needed a source-controlled edit. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RLSNJhNoULvVcUhXEFafQC
This commit is contained in:
parent
a8fb768526
commit
7982f28557
6 changed files with 111 additions and 3 deletions
|
|
@ -24685,6 +24685,32 @@
|
|||
],
|
||||
"occurrences": 1,
|
||||
"last_seen": "2026-09-20T10:00:00Z"
|
||||
},
|
||||
{
|
||||
"id": "bug-1833",
|
||||
"timestamp": "2026-09-20T11:00:00Z",
|
||||
"error_message": "NOT A CRASH -- proactive hardening, user-requested, following bug-1831/bug-1832. Nothing in xceadmin's config validation caught a percent-based limit's value being outside the valid 0.0-1.0 fraction range (e.g. 'value: 50, percent: true', meant to express 50% but computing as 5000% of the resource) -- both night_mem_pct in the real src/configs/limits.yaml (bug-1832) and, discovered while adding this validation, an identical stale value in the xceadmin test suite's own checked-in golden fixture (src/xceadmin/tests/fixtures/full/configs/limits.yaml) had this exact defect.",
|
||||
"file": "src/configs/schema/limits.schema.json",
|
||||
"root_cause": "limits.schema.json's Limit definition had `\"value\": {\"type\": \"number\"}` with no range constraint at all, and no conditional (if percent then range) constraint existed anywhere in this codebase's 7 bundled JSON schemas -- confirmed no if/then usage exists in any of them prior to this fix.",
|
||||
"fix": "FIXED (2026-09-20). Added an if/then JSON Schema (draft 2020-12) conditional constraint to the Limit definition: `if percent == true, then value must be a number in [0.0, 1.0]`. Empirically verified against the real jsonschema==4.26.0 library this repo uses -- a violation surfaces with the exact same file/json_pointer/constraint contract validate_yaml()'s existing ValidationError already provides (constraint='maximum'/'minimum'), so zero changes were needed to validation.py's own error-reporting code. This is now enforced at real `xceadmin config build` time (deploy-ha.sh's actual cluster.bin generation path), not merely a unit-test-only check. IMPORTANT BUILD GOTCHA discovered while implementing this: this repo has TWO copies of every bundled JSON schema -- src/configs/schema/*.schema.json (the REAL canonical source) and src/xceadmin/src/xcecommon/schema_files/json/ (a checked-in mirror). meson-build.sh:104 ALWAYS overwrites the xceadmin copy from src/configs/schema/ during any real build (`cp \"$SRC_DIR/configs/schema/\"*.schema.json \"$SCHEMA_DST/json/\"`) -- editing ONLY the xceadmin-tree copy is silently discarded on the next build. Both copies were edited to stay in sync. Also fixed the same night_mem_pct value: 50 -> 0.5 defect the new constraint caught in the xceadmin test suite's own checked-in 'full' golden fixture, and regenerated its checked-in expected.bin golden artifact to match (via build.build_cluster_config()). Added 3 new tests to test_validation.py covering: reject out-of-range percent value, accept in-range percent value, and confirm a non-percent value is never range-checked regardless of magnitude.",
|
||||
"tags": [
|
||||
"xceadmin",
|
||||
"config-validation",
|
||||
"json-schema",
|
||||
"limit-plugin",
|
||||
"percent-limit",
|
||||
"proactive-hardening",
|
||||
"fixed",
|
||||
"related-to-bug-1831",
|
||||
"related-to-bug-1832",
|
||||
"build-gotcha"
|
||||
],
|
||||
"related_bugs": [
|
||||
"bug-1831",
|
||||
"bug-1832"
|
||||
],
|
||||
"occurrences": 1,
|
||||
"last_seen": "2026-09-20T11:00:00Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue