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
@@ -587,9 +587,7 @@ void read_config_json(const std::string& dir, VocabBuild& out) {
|
||||
json c = json::parse_container(text, &over, &deep);
|
||||
if (over || deep || c.is_discarded()) {
|
||||
RAD_WARN("tokenizer: %s did not read as a bounded JSON document (%s); ids left unset",
|
||||
path.c_str(),
|
||||
over ? "it carries far too many values"
|
||||
: deep ? "it nests far too deep" : "it does not parse");
|
||||
path.c_str(), json::bound_why(over, deep));
|
||||
return;
|
||||
}
|
||||
std::unordered_map<std::string, int32_t> id_of;
|
||||
@@ -793,9 +791,10 @@ int parse_tokenizer_json_buf(std::string_view text, const char* origin, VocabBui
|
||||
bool over = false, deep = false;
|
||||
json j = json::parse_container(text, &over, &deep);
|
||||
if (over || deep) {
|
||||
RAD_ERR("%s: %s; a tokenizer file may not carry more than 2^24 values or nest more "
|
||||
"than 256 levels",
|
||||
origin, over ? "carries far too many values" : "nests far too deep");
|
||||
RAD_ERR("%s: %s; a tokenizer file may not carry more than %lld values or nest more "
|
||||
"than %d levels",
|
||||
origin, json::bound_why(over, deep),
|
||||
(long long)json::kContainerBudget, json::kContainerDepth);
|
||||
return RAD_E_FORMAT;
|
||||
}
|
||||
if (j.is_discarded()) {
|
||||
|
||||
Reference in new issue
Block a user