Skip to content

Commit 4fd89fe

Browse files
committed
Fix JSON backend bug when missing attributes
1 parent 1d64302 commit 4fd89fe

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/IO/JSON/JSONIOHandlerImpl.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,15 @@ void JSONIOHandlerImpl::readAttribute(
15381538
refreshFileFromParent(writable);
15391539
auto name = removeSlashes(parameters.name);
15401540
auto const &jsonContents = obtainJsonContents(writable);
1541+
if (!hasKey(jsonContents, "attributes"))
1542+
{
1543+
throw error::ReadError(
1544+
error::AffectedObject::Attribute,
1545+
error::Reason::NotFound,
1546+
"JSON",
1547+
"Tried looking up attribute '" + name + "' at location: " +
1548+
setAndGetFilePosition(writable, false)->id.to_string());
1549+
}
15411550
auto const &jsonLoc = jsonContents["attributes"];
15421551
setAndGetFilePosition(writable);
15431552
if (!hasKey(jsonLoc, name))

0 commit comments

Comments
 (0)