Cover error paths for union vectors and mismatched schemas - #12
Merged
Merged
Conversation
## Why Four reachable error branches had no tests: the writer's handling of union vectors (which the schema parser accepts but the writer cannot encode), and get/4's defense against a schema whose entities disagree with the buffer (an unrecognized field type, or a missing table definition). ## What - Writing a vector of unions throws wrong_type per element; writing an empty one throws unknown_scalar when sizing the elements. - get/4 raises BadFlatbufferError when the schema names a field type reading does not recognize, and when the table definition for the path is absent from the schema. Coverage rises from 98.5% to 99.3%; access.ex and reading.ex reach 100%. The three remaining uncovered lines are defensive clauses unreachable through any parseable schema. Claude-Session: https://claude.ai/code/session_014wfX6262n6A6qBPCXEo6Gz
Elixir 1.19 warns on a struct update when the variable is not proven
to be that struct, and CI runs with --warnings-as-errors. Match on
%Flatbuffer.Schema{} at binding and use plain map updates, as the
compiler hint suggests.
Claude-Session: https://claude.ai/code/session_014wfX6262n6A6qBPCXEo6Gz
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.
Why
Four reachable error branches had no tests: the writer's handling of union vectors (which the schema parser accepts but the writer cannot encode), and
get/4's defense against a schema whose entities disagree with the buffer.What
wrong_typeper element; writing an empty one throwsunknown_scalarwhen sizing the elements.get/4raisesBadFlatbufferErrorwhen the schema names a field type reading does not recognize, and when the table definition for the path is absent from the schema.Coverage rises from 98.5% to 99.3%;
access.exandreading.exreach 100%. The three remaining uncovered lines are defensive clauses unreachable through any parseable schema (sizeoffor vectors-of-vectors, which the grammar rejects, and the writer's bare-atomwithout_default/alignmentfallbacks).https://claude.ai/code/session_014wfX6262n6A6qBPCXEo6Gz