util: one wording for the bounded read's refusal

The refuse sites that read a container file all re-typed the same
two-branch message -- over ? "carries far too many values"
: "nests far too deep" -- six times, and the copies had already
drifted: gen_config said "carries far too many JSON values", xstats
"far too many values", tokenizer_config "it does not parse" for the
discarded case. The bounds themselves (2^24, 256) were also spelled
as literals in tokenizer_json's refusal, so a bound change there
would make its message a lie.

Json::bound_why(over, deep) is the phrase, owned beside the read that
sets the flags, and the two bounds are exported as kContainerBudget /
kContainerDepth so the one message that states them reads them from
the constants. Every refuse site now calls it; the wording is one, the
numbers cannot drift. No behaviour change -- the same flags map to the
same failure paths, only the text they print is unified.
This commit is contained in:
fl0l0u committed 2026-11-15 22:02:29 +00:00
1 parent 5e2e596644
commit b9ecbde0d6
6 files changed
+23 -14

No files matched your search

+1 -2
View File
@@ -815,8 +815,7 @@ int load_adapter(const std::string& dir, const std::vector<Site>& sites, int max
bool over = false, deep = false;
const ojson cfg = ojson::parse_container(text, &over, &deep);
if (over || deep)
return fail(err, RAD_E_FORMAT,
cfg_path + (over ? ": carries far too many JSON values" : ": nests far too deep"));
return fail(err, RAD_E_FORMAT, cfg_path + ": " + ojson::bound_why(over, deep));
if (cfg.is_discarded() || !cfg.is_object())
return fail(err, RAD_E_FORMAT, cfg_path + ": not a JSON object");
auto truthy = [&](const char* k) {