Archived
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:
1 parent
5e2e596644
commit
b9ecbde0d6
6 files changed
+23
-14
No files matched your search
+2
-4
@@ -99,8 +99,7 @@ bool gen_sampling_parse(const std::string& json_text, const char* src, GenSampli
|
||||
bool over = false, deep = false;
|
||||
Json j = Json::parse_container(json_text, &over, &deep);
|
||||
if (over || deep) {
|
||||
RAD_WARN("%s: %s; ignoring it", src,
|
||||
over ? "carries far too many JSON values" : "nests far too deep");
|
||||
RAD_WARN("%s: %s; ignoring it", src, Json::bound_why(over, deep));
|
||||
return false;
|
||||
}
|
||||
if (j.is_discarded()) { RAD_WARN("%s: not valid JSON; ignoring it", src); return false; }
|
||||
@@ -222,8 +221,7 @@ bool gen_sampling_from_kv(const std::function<const char*(const char*)>& get, Ge
|
||||
if (over || deep)
|
||||
RAD_WARN("the container states generation.%s as \"%s\", which is not a JSON "
|
||||
"array of ids (%s); ignoring it",
|
||||
k, log_sanitize(v).c_str(),
|
||||
over ? "it carries far too many values" : "it nests far too deep");
|
||||
k, log_sanitize(v).c_str(), Json::bound_why(over, deep));
|
||||
else if (!w.is_discarded()) j[k] = std::move(w);
|
||||
else
|
||||
RAD_WARN("the container states generation.%s as \"%s\", which is not a JSON "
|
||||
|
||||
Reference in new issue
Block a user