Skip to content

Cover error paths for union vectors and mismatched schemas - #12

Merged
jallum merged 2 commits into
mainfrom
test/cover-error-paths
Aug 31, 2026
Merged

jallum merged 2 commits into
mainfrom
test/cover-error-paths

Conversation

@jallum

@jallum jallum commented Aug 31, 2026

Copy link
Copy Markdown
Owner

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

  • 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 (sizeof for vectors-of-vectors, which the grammar rejects, and the writer's bare-atom without_default/alignment fallbacks).

https://claude.ai/code/session_014wfX6262n6A6qBPCXEo6Gz

jallum added 2 commits August 31, 2026 13:06
## 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
@jallum
jallum merged commit ba01e18 into main Aug 31, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant