Repository navigation
fix(json): return a parse error for a list type missing 'element' - #997
Merged
wgtmac merged 1 commit intoOct 11, 2026
Merged
Conversation
ListTypeFromJson read the nested element type with the raw const json[kElement] accessor, which is undefined behavior (an assertion in debug nlohmann builds) when a list type object is missing the required 'element' key. Use GetJsonValue<nlohmann::json>(json, kElement) like the sibling MapTypeFromJson does, so malformed schema or table-metadata JSON yields JsonParseError instead of asserting.
wgtmac
approved these changes
Oct 11, 2026
Contributor
Author
|
Thank you @wgtmac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
ListTypeFromJsoninsrc/iceberg/json_serde.ccread the element type with the constjson[kElement]accessor. For a list type object without an"element"key this is undefined behavior in nlohmann: with assertions enabled it aborts onJSON_ASSERT, and underNDEBUGit dereferences the end iterator. Table metadata with a list-typed field that lacks"element"reaches it throughSchemaFromJson.Follow-up to #982 (#982 (review)). Closes #996.
How
Read the key with
GetJsonValue<nlohmann::json>(json, kElement)and pass the result toTypeFromJson, the same wayMapTypeFromJsonreadskeyandvalue. A missing key now returnsJsonParseError. This was the only constjson[key]read insrc/icebergthat did not check the key exists first.Testing
JsonInternalTest.ListTypeFromJsonMissingElementpasses a list type without"element"toTypeFromJsonand expectskJsonParseErrorwith "Missing 'element'". Without the fix the test aborts withAssertion failed: (it != m_data.m_value.object->end())injson.hpp.