Skip to content

cargo clippy fails: non-exhaustive match on nbformat::Notebook (missing V3 arm) in NotebookVfs #75

Description

@AttilaMihaly

Summary

cargo clippy --package morphir --all-targets -- -D warnings fails to compile morphir-common with:

error[E0004]: non-exhaustive patterns: `nbformat::Notebook::V3(_)` not covered
  --> crates/morphir-common/src/vfs/notebook.rs:23:33
   |
23 |         let v4_notebook = match notebook {
   |                                 ^^^^^^^^ pattern `nbformat::Notebook::V3(_)` not covered

NotebookVfs::from_notebook (crates/morphir-common/src/vfs/notebook.rs:20-38) matches on nbformat::Notebook with arms for V4 and Legacy only.

Root cause

Cargo.toml pins nbformat = "1.0" (i.e. ^1.0, any 1.x). The committed Cargo.lock in this repo resolves that to 1.0.0, where Notebook only has V4/Legacy variants, so the match is exhaustive as committed and cargo build/cargo test against the locked versions pass fine.

The bug is latent rather than absent: nbformat has since published 1.2.2, which adds a Notebook::V3 variant. Anything that re-resolves the lockfile against the current registry (a fresh cargo generate-lockfile, cargo update, or a consumer with a looser lock) picks up 1.2.2 and the match stops being exhaustive.

Where this actually bit us

In the parent finos/morphir monorepo, the morphir CLI CI job runs prepare_cli_workspace.py before building, which deletes Cargo.lock and runs cargo generate-lockfile fresh (to build the CLI-only workspace without morphir-live). That resolves nbformat to 1.2.2 and the job fails on this exhaustiveness check.

This is currently blocking otherwise-unrelated PRs in finos/morphir — confirmed via finos/morphir#626, which only touches .github/workflows/*.yml (no Rust/Cargo changes at all) and still hits this exact error, since it's the CI job's fresh lockfile resolution surfacing a pre-existing gap in this repo's code, not anything introduced by that PR. See the failing run: https://github.com/finos/morphir/actions/runs/32068606383/job/95506448404

Also affects finos/morphir#638 and finos/morphir#612.

Suggested fix

Add a Notebook::V3(_) arm to the match in notebook.rs, analogous to how Legacy is currently handled (falls back to an empty v4::Notebook) — or implement an actual V3→V4 conversion if that's preferable. A todo!()/unimplemented!() stub would compile but just move the failure to runtime, so real handling (even if it's "unsupported, return an error") is preferable to silence clippy.

Alternatively/additionally, consider whether nbformat = "1.0" should be tightened (e.g. "~1.0" or exact-pinned) so a routine lockfile regeneration doesn't silently pick up a semver-compatible release that adds unhandled enum variants.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions