Skip to content

api: mark Format as #[non_exhaustive] - #154

Open
marcellmanfrin wants to merge 2 commits into
firecrawl:mainfrom
marcellmanfrin:fix/format-non-exhaustive
Open

api: mark Format as #[non_exhaustive]#154
marcellmanfrin wants to merge 2 commits into
firecrawl:mainfrom
marcellmanfrin:fix/format-non-exhaustive

Conversation

@marcellmanfrin

@marcellmanfrin marcellmanfrin commented Sep 1, 2026

Copy link
Copy Markdown

Scope

Marks the public Format enum #[non_exhaustive] and adds defensive wildcard arms to the in-repo Node and WASM bindings. No conversion behavior changes.

Motivation

#147 and #149 add Html and Mhtml variants to Format. Adding a variant to a public enum breaks downstream users with exhaustive match expressions (flagged by Cubic on #149, src/lib.rs:50). #[non_exhaustive] makes future variant additions forward-compatible: crates outside this workspace must include a wildcard arm, while references like Format::Pdf keep working unchanged.

Changes

  • src/lib.rs: #[non_exhaustive] on Format + doc note.
  • node/src/lib.rs and wasm/src/lib.rs: the bindings match anydoc::Format exhaustively in From<anydoc::Format>, so each gains an explicit other => unreachable!(...) arm. The bindings are released in lockstep with the core crate; the arm is defensive only.
  • Python bindings are untouched: they resolve format names through a lookup table, not an exhaustive match.

Validation (full gate on the exact candidate SHA 73f851b66c8f1926221bb4e4028e833e88685ef2, Windows, cargo 1.98.0)

  • Rust: cargo fmt --all --check, cargo clippy --workspace --all-targets --all-features -- -D warnings, cargo test --locked — all clean, all suites pass.
  • Node: npm ci / npm run build / npm test — 19 passed, 0 failed; committed node/index.js / node/index.d.ts are deterministic (zero diff after rebuild).
  • WASM: wasm32 Clippy clean; wasm-pack build wasm --release --target web --scope firecrawl; node --test wasm/test.mjs — 8 passed, 0 failed.
  • Python: locked Maturin release wheel, installed into a clean venv from site-packages, python -m unittest discover -s python/tests from the repo root — 11 tests OK.

Fixture note: this candidate is based on main, which intentionally does not include HTML/MHTML support, so the private real-fixture conversion matrix from the repository policy does not apply here (this PR changes no conversion logic).


Summary by cubic

Marks the Format enum #[non_exhaustive] so future variant additions (like the in-flight Html and Mhtml) won't break downstream matches. Downstream callers must now include a wildcard arm when matching. Adds defensive unreachable!() arms to the Node and WASM bindings' From<anydoc::Format> implementations; the Python bindings are unchanged since they resolve format names via a lookup table. No conversion behavior changes.

Written for commit 7a5c8ba. Summary will update on new commits.

Review in cubic

New formats are added over time: standalone HTML and MHTML support are
in flight in firecrawl#147 and firecrawl#149. Adding a variant to the public Format enum
breaks downstream users that match it exhaustively. Mark the enum
#[non_exhaustive] so future variants are forward-compatible: crates
outside this workspace must include a wildcard arm when matching.

The in-repo Node and WASM bindings match anydoc::Format exhaustively,
so add an explicit unreachable arm to each From<anydoc::Format>
implementation; the bindings are released in lockstep with the core
crate, so the arm is defensive only. The Python bindings resolve
format names through a lookup table and need no change.

Motivated by the Cubic finding on firecrawl#149 (src/lib.rs:50).

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread src/lib.rs Outdated
Cubic finding (PR 154, src/lib.rs): the doc note wrongly implied that
downstream exhaustive matches keep compiling. #[non_exhaustive]
requires downstream callers to match with a wildcard arm; only
wildcard-bearing matches remain compatible with future variants.

Full gate re-run on this exact tree: Rust fmt/clippy/tests clean,
Node 19/19 with deterministic bindings, WASM 8/8, Python 11/11.
@marcellmanfrin

Copy link
Copy Markdown
Author

@cubic-dev-ai ultrareview: focus on the #[non_exhaustive] API change and the wildcard arms added to the Node/WASM bindings.

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 1, 2026

Copy link
Copy Markdown

@cubic-dev-ai ultrareview: focus on the #[non_exhaustive] API change and the wildcard arms added to the Node/WASM bindings.

@marcellmanfrin Couldn't start the ultrareview: PR author marcellmanfrin has no assigned seat on this installation. Please, assign one at https://www.cubic.dev/settings?tab=subscription.

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