You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following try/catch block exists in the get_or_create_ref function:
try {
auto &subschema = file.unknown_keywords.at(uri.pointer()); // null is returned if not existing
auto s = schema::make(subschema, this, {}, {{uri}}); // A JSON Schema MUST be an object or a boolean.
if (s) { // nullptr if invalid schema, e.g. null
file.unknown_keywords.erase(uri.fragment());
return s;
}
} catch (nlohmann::detail::out_of_range &) { // at() did not find it
}
An out_of_range exception from nlohmann::json::at() is thrown when there is no schema to be found with the given JSON pointer, and this seems to be expected. It is generally frowned upon to use exceptions like this, ref isocpp. I would like to suggest the following fix using nlohmann::json::find instead:
auto subschema_it = file.unknown_keywords.find(uri.pointer());
if (subschema_it != file.unknown_keywords.end()) { // if found
auto &subschema = subschema_it->second;
auto s = schema::make(subschema, this, {}, {{uri}});
if (s) { // if schema is valid (non-null)
file.unknown_keywords.erase(uri.fragment());
return s;
}
}
Noted this issue as our repository started to use more json references, this exception ends up being thrown a lot.
The text was updated successfully, but these errors were encountered:
@pboettch Unsure how to debug or re-run the CI builds failing on that PR. Does not seem like I have the ability to re-trigger them. May need assistance there! 🙏
The following try/catch block exists in the get_or_create_ref function:
An
out_of_range
exception fromnlohmann::json::at()
is thrown when there is no schema to be found with the given JSON pointer, and this seems to be expected. It is generally frowned upon to use exceptions like this, ref isocpp. I would like to suggest the following fix usingnlohmann::json::find
instead:Noted this issue as our repository started to use more json references, this exception ends up being thrown a lot.
The text was updated successfully, but these errors were encountered: