LuciferYang opened a new pull request, #982:
URL: https://github.com/apache/iceberg-cpp/pull/982

   ## What
   
   Expression JSON deserialization in `src/iceberg/expression/json_serde.cc` 
called `json[kType].get<std::string>()` (and one 
`json[kTerm].get<std::string>()`) guarded only by `is_object()` and 
`contains(kType)`. A non-string `"type"`/`"term"` made nlohmann throw 
`json::type_error.302`, which escaped these `Result`-returning functions (the 
expression parse chain has no `try`/`catch`) and terminated the caller instead 
of returning an error. This is the same failure mode as the merged #857.
   
   It is reachable, not test-only. Table-metadata parsing hits the type-aware 
`LiteralFromJson` through `FieldFromJson`'s `initial-default`/`write-default` 
handling, and REST responses hit the expression parsers through the 
scan-metrics report filter and the residual/partition/plan filters, all via 
`ICEBERG_ASSIGN_OR_RAISE`, which forwards a `Result` error but not a thrown 
exception.
   
   Closes #979.
   
   ## How
   
   Each of the six `get<std::string>()` sites now checks `is_string()` first 
and returns `JsonParseError` on a non-string node, mirroring the sibling 
`OperationTypeFromJson`. Valid string input is unaffected: the added 
`is_string()` sits in a short-circuit `&&`, so a well-formed node evaluates 
exactly as before, and the guard only rejects input that previously threw.
   
   ## Testing
   
   `NonStringTypeIsParseError` in `expression_json_test.cc` covers all six 
guards: a non-string `"type"` at the top level (`ExpressionFromJson`), on an 
and/or node, on a predicate's term node (routed through the transform-term 
check and then the named-reference parser), a non-string reference `"term"`, 
and a non-string `"type"` on both the untyped and the type-aware 
`LiteralFromJson` overloads. Each case returns `kJsonParseError`; without the 
fix the corresponding input throws `json::type_error.302` out of the 
`Result`-returning function. Removing any single guard makes one of these cases 
throw, so no guard is left unpinned.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to