Skip to content

bug(session): --cut reports direct_import: true for nonexistent targets #151

@rocketman-code

Description

@rocketman-code

Current Behavior

When running `chainsaw trace --cut nonexistent-pkg`, the CutReport has `direct_import: true` even though the target does not exist in the graph. This is because the condition `cuts.is_empty() && chains.iter().all(|c| c.len() == 2)` evaluates to true when chains is empty (vacuous truth of `all()` on empty iterator).

Expected Behavior

When the target is not found in the graph (no chains), `direct_import` should be `false`. The report should indicate the target was not found, not that it's a direct import.

Context

This produces misleading output telling users to "remove the import" for a package that doesn't even exist in the graph.

Technical Details

Relevant Code

`src/session.rs:498`

```rust
direct_import: cuts.is_empty() && chains.iter().all(|c| c.len() == 2),
```

When `chains` is empty, `all()` returns `true` (vacuous truth), and `cuts.is_empty()` is also `true`, so `direct_import` is incorrectly `true`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low prioritybugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions