Skip to content

fix: prevent unreachable!() panic in decode when pkgs checkout is absent - #1087

Merged
twitchyliquid64 merged 1 commit into
mainfrom
inbox-patch/decode-var-buildspec-panic-93767d4485e1ef40
Jul 29, 2026
Merged

fix: prevent unreachable!() panic in decode when pkgs checkout is absent#1087
twitchyliquid64 merged 1 commit into
mainfrom
inbox-patch/decode-var-buildspec-panic-93767d4485e1ef40

Conversation

@gominimal-aw-bot

@gominimal-aw-bot gominimal-aw-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #1066
Routing-Key: inbox-route/I_kwDOSUhdos8AAAABKsihnA

min init/min add panicked with unreachable!() at load.rs:345
when --minimal-dir had no upstream pkgs checkout: annotate_record!
assumed a build-spec term is always Term::RecRecord, but with the
checkout absent the spec field stays an unresolved Term::Var and hits
the fallthrough panic. The fix returns the term unchanged for non-record
shapes (mirroring the macro's existing minimal-library skip arm), so
evaluation reports a real error instead of aborting; that arm was only
ever reached via the panic, so no working flow regresses. Added a
regression test reproducing the exact Var(spec) shape (informed by #81).

Verification

cargo fmt --all --check — clean, no drift
cargo clippy --workspace --locked -- -D warnings — 0 warnings
cargo build --workspace --locked — Finished, exit 0
cargo test --workspace --locked — 0 failed; decode 57/57 incl. loader_annotates_buildspec_via_var

Generated by inbox-patch ·

Note

Fix unreachable!() panic in annotate_record macro when annotated term is not a record

When a build-spec annotation sits on a non-record term (e.g., Term::Var), the annotate_record macro previously hit an unreachable!() panic. The macro now returns Ok(orig_val) instead, allowing evaluation to surface the error rather than aborting. A regression test in load.rs confirms that a spec referencing a variable no longer causes Loader::new to panic.

Macroscope summarized f480ef4.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of build-spec annotations applied to non-record values.
    • Replaced an internal crash with a proper evaluation error, providing more reliable behavior for variable-based and missing checkout scenarios.

The annotate_record! macro assumed a build-spec-annotated term is
always a Term::RecRecord and hit unreachable!() on anything else.
When --minimal-dir points at a directory with no upstream pkgs
checkout, the spec field survives as an unresolved Term::Var, so
`min init` and `min add` aborted with an internal-error panic at
load.rs:345 on the host-side build plane.

Return the original value unchanged for non-record terms, leaving
them unannotated, so evaluation surfaces a real error instead of
panicking. This mirrors the existing minimal-library skip branch in
the same macro. The `_` arm was previously reachable only via the
panic, so no working flow depends on the old behavior.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7e587cc8-1424-4e35-ad20-d57504914a5d

📥 Commits

Reviewing files that changed from the base of the PR and between 0e25232 and f480ef4.

📒 Files selected for processing (1)
  • crates/decode/src/load.rs

📝 Walkthrough

Walkthrough

The loader now leaves non-record build-spec annotations unchanged instead of panicking. A regression test covers annotations applied through a variable reference.

Changes

Build-spec annotation handling

Layer / File(s) Summary
Preserve non-record terms and test variable annotations
crates/decode/src/load.rs
annotate_record! returns non-record terms unchanged, and loader_annotates_buildspec_via_var verifies that variable-based build-spec annotations complete without the previous panic.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • gominimal/inbox#419 — Directly concerns the unreachable!() panic when build-spec annotations resolve to Term::Var.

Suggested reviewers: twitchyliquid64

Poem

I’m a rabbit who hops through the loader tonight,
No unreachable burrow comes into sight.
A variable carries the spec on its way,
And tests keep the crash-panic at bay.
Thump, thump—annotations now play fair!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@twitchyliquid64
twitchyliquid64 marked this pull request as ready for review July 29, 2026 22:12
@twitchyliquid64
twitchyliquid64 merged commit 7cbede3 into main Jul 29, 2026
28 of 29 checks passed
@twitchyliquid64
twitchyliquid64 deleted the inbox-patch/decode-var-buildspec-panic-93767d4485e1ef40 branch July 29, 2026 22:12
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.

min init/min add panic with unreachable!() when --minimal-dir points at a directory with no upstream checkout

1 participant