Skip to content

test(cli): nothing stops a new PackageSource variant reaching the "unknown" token #145

Description

@justin13888

What this run demonstrated

source_token in crates/dependable/src/output/list.rs ends in _ => "unknown". PackageSource is #[non_exhaustive], so a variant added without a matching arm compiles, passes every test, and ships "source": "unknown" in list --format json with nothing failing.

That is not hypothetical. Two open pull requests each added a variant to that enum without knowing about the other:

They sit on the same stack. A merge resolution that kept one side's arm and dropped the other would have produced exactly the silent outcome above. The merge was resolved correctly and both arms survive today — but nothing in the repository would have caught it if they had not.

Why the existing guards do not cover it

ALL_KINDS's guard in crates/dependable-core/src/manifest.rs is the nearest analogue, and #124 records that it has the same class of gap: a guard that iterates a hand-maintained list cannot detect an omission from that list.

An exhaustive match in the defining crate would catch it, but source_token lives in the binary crate, where #[non_exhaustive] forces a wildcard arm and exhaustiveness is unavailable.

Direction

A test that enumerates every PackageSource variant and asserts source_token returns something other than "unknown" for each. The enumeration is the part that must not be hand-maintained, or the test inherits the same defect it is meant to close — the same objection #124 raises against ALL_KINDS.

The same argument applies to annotation() in that file, though less sharply: there, falling through is sometimes the intended answer (Locked deliberately has no arm and is documented as such), so the assertion has to be "the variant was considered", not "the variant renders".

Worth deciding at the same time: whether "unknown" should exist as a token at all, or whether an unmapped variant should be a panic in debug builds so it cannot reach a user.

Context

Raised while propagating repaired bases down the #95#97#103#115 stack, where the two variants met. A full audit of all 19 sites discriminating on PackageSource was done as part of that merge and every site is correct today; this issue is about the absence of anything that keeps them correct.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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