Skip to content

fix(deserialize): report rejected scalar enum span - #70

Open
TeamDman wants to merge 1 commit into
facet-rs:mainfrom
TeamDman:fix/scalar-enum-error-span
Open

TeamDman wants to merge 1 commit into
facet-rs:mainfrom
TeamDman:fix/scalar-enum-error-span

Conversation

@TeamDman

@TeamDman TeamDman commented Oct 6, 2026

Copy link
Copy Markdown

Report the peeked scalar's span for unknown enum variants

Closes #69.

Invalid scalar enum values currently inherit the previous consumed event's
span. In Cloud Terrastodon's Figue CLI, an invalid --output-format value can
therefore underline an unrelated preceding authentication argument.

Use event.span in the external-enum no-match/no-fallback error branch. The
event was only peeked, so self.last_span still belongs to a previous event.
The error kind and path, valid enum decoding, catch-all fallback, and parser
consumption behavior remain unchanged. Clarify the consumed-versus-peeked span
rule in the deserializer's documentation.

Add a Format-library regression that consumes one synthetic scalar before
rejecting another as a unit enum variant. It checks the rejected value's exact
span and error kind with both single-event and default-size buffers. The test
adds Facet as a development dependency to derive its enum; it has no JSON
fixtures or Figue dependency.

Validation

Based on official Format main
4279debff780ae1cd5b028201f446c26594b1120,
freshly fetched on 2026-10-06.

  • Before the one-line span fix, the new regression fails: actual
    Span { offset: 14, len: 7 }, expected Span { offset: 38, len: 5 }.
  • After the fix, all six facet-format library tests pass with
    cargo +1.96.0 test -p facet-format --lib --offline --locked.
  • cargo +1.96.0 fmt -p facet-format -- --check and git diff --check pass.
  • Tests run on Windows with Rust 1.96.0. They use typed synthetic events and no
    production data, credentials, application caches, or service calls.

The issue/PR pair for native enum aliases is independent: this change repairs
diagnostic location for values that still legitimately fail enum decoding.

Prepared with assistance from OpenAI Codex (GPT-6).

@codecov

codecov Bot commented Oct 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.67568% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
facet-format/src/deserializer/eenum.rs 75.67% 9 Missing ⚠️

📢 Thoughts on this report? Let us know!

@TeamDman
TeamDman marked this pull request as ready for review October 6, 2026 14:28

This branch has not been deployed

No deployments
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.

Invalid scalar enum errors underline the previous value

1 participant