Skip to content

fix: add apply diagnostics for silent no-op failures#53

Open
Wenxin-Jiang wants to merge 1 commit intomainfrom
fix/apply-diagnostics
Open

fix: add apply diagnostics for silent no-op failures#53
Wenxin-Jiang wants to merge 1 commit intomainfrom
fix/apply-diagnostics

Conversation

@Wenxin-Jiang
Copy link
Copy Markdown
Contributor

Summary

  • Track unmatched manifest entries: After the apply loop, compares targeted manifest PURLs against actually-matched PURLs. Any unmatched entry produces a warning with the specific PURL. Correctly handles PyPI qualified variants and respects --ecosystems filtering.
  • Fail when nothing matches: Changes exit code from 0 to 1 when the manifest has patches in scope but no matching packages are found on disk. Also fails when packages are discovered but none match any targeted manifest entry.
  • Post-apply summary: Prints Summary: X/Y targeted patches applied, Z already patched, W not found on disk so the user always sees the gap.
  • JSON output: Adds unmatchedPatches (count) and unmatchedPurls (list) to --json output.

Addresses findings CRITICAL-1 (zero packages → exit 0), CRITICAL-2 (version mismatch → silent skip), and CRITICAL-3 (no unmatched-manifest diagnostic) from the reliability audit.

Test plan

  • cargo check -p socket-patch-cli compiles
  • cargo test -p socket-patch-cli passes
  • cargo test -p socket-patch-core passes (255 tests)
  • Manual: run apply in a dir with manifest but no node_modules/ — should exit 1 with warning
  • Manual: run apply after npm update changes a version — should warn about unmatched PURL
  • Manual: run apply --ecosystems npm with pypi patches in manifest — pypi patches should NOT appear as unmatched
  • Manual: run apply --json — verify unmatchedPatches and unmatchedPurls fields

🤖 Generated with Claude Code

When `apply` runs in CI and no packages match manifest patches, it
previously exited 0 silently, masking configuration errors. This change:

- Tracks which manifest entries actually matched installed packages
- Returns exit code 1 when targeted patches exist but nothing matched
- Emits per-PURL warnings for unmatched manifest entries
- Adds a post-apply summary (applied/already-patched/not-found counts)
- Includes `unmatchedPatches` and `unmatchedPurls` in JSON output
- Changes `apply_patches_inner` signature to return unmatched PURLs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Wenxin-Jiang
Copy link
Copy Markdown
Contributor Author

@claude review once

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