Skip to content

[ANE-Bot] Tolerate Maven plugin scratch dir removed before cleanup - #1771

Open
fossa-ane-bot wants to merge 2 commits into
masterfrom
fossa-cli-fix-2026-09-05
Open

[ANE-Bot] Tolerate Maven plugin scratch dir removed before cleanup#1771
fossa-ane-bot wants to merge 2 commits into
masterfrom
fossa-cli-fix-2026-09-05

Conversation

@fossa-ane-bot

Copy link
Copy Markdown
Contributor

Overview

Maven analysis unpacks the depgraph plugin jar into a scratch directory created under the system temp directory (fossa-maven-*). Cleanup of that directory was done with a hand-rolled bracket / removeDirRecur pair that escalated any IO error during removal into a fatal, analysis-wide error. When the OS temp reaper (or a concurrent task) removed the directory before cleanup ran, the entire run died with:

Error: An exception occurred:/tmp/fossa-maven-XXXX: removeDirectoryRecursive:getSymbolicLinkStatus: does not exist (No such file or directory)
    Traceback:
      - discovery/analysis tasks
      - fossa-analyze

The traceback shows the exception escaping at the top level (no strategy context), i.e. it was not handled as a recoverable diagnostic — a successful Maven analysis was thrown away because of a temp-directory cleanup race.

The fix replaces the hand-rolled cleanup in withUnpackedPlugin with withSystemTempDir, which removes the scratch directory on a best-effort basis (it routes cleanup through path-io, which ignores IO errors during removal). This matches how every other temp directory in the analyzer is handled — including the immediately-following withSystemTempDir "fossa-depgraph" call in the same analyze function.

This is an internal robustness fix: no user-visible schema, CLI flag, or documented behavior changes, so the docs / schema / subcommand checklist items below are left unchecked.

Acceptance criteria

When a Maven project is analyzed and the plugin scratch directory is removed before cleanup runs, analysis no longer aborts with An exception occurred: /tmp/fossa-maven-... removeDirectoryRecursive:getSymbolicLinkStatus: does not exist. Cleanup failures are silently tolerated, as they are for every other analyzer temp directory.

Testing plan

  1. Build the CLI: cabal build (or make build-cli).
  2. Unit test (added here): cabal test unit-tests --test-options='--match "withUnpackedPlugin"'. The new case invokes withUnpackedPlugin and deletes the scratch directory from inside the callback, then asserts the call still returns normally. Against the previous cleanup code this case fails with the removeDirectoryRecursive exception; with the fix it passes.
  3. Manual: run fossa analyze against any Maven project and, in a parallel shell, delete the /tmp/fossa-maven-* directory that appears during the depgraph plugin step. Before this change the run fails with the exception above; after it, analysis completes.

Risks

Low. The change narrows failure behavior only (a cleanup error that used to be fatal is now ignored), and reuses the same withSystemTempDir helper already used throughout the analyzer. The scratch directory is still created under the system temp directory and still removed on the success path.

Metrics

Sourced from the fossa-cli-dashboard Error patterns widget (source:fossa-cli status:error). Over the scan window (2026-09-04 02:45 UTC to 2026-09-05 01:44 UTC), this exception clustered 36 times on supported CLI minors (v3.17/v3.18). The same widget can confirm the pattern drops off after this fix releases.

References

Checklist

  • I added tests for this PR's change (or explained in the PR description why tests don't make sense).
  • If this PR introduced a user-visible change, I added documentation into docs/.
  • If this PR added docs, I added links as appropriate to the user manual's ToC in docs/README.ms and gave consideration to how discoverable or not my documentation is.
  • If this change is externally visible, I updated Changelog.md. If this PR did not mark a release, I added my changes into an ## Unreleased section at the top.
  • If I made changes to .fossa.yml or fossa-deps.{json.yml}, I updated docs/references/files/*.schema.json AND I have updated example files used by fossa init command. You may also need to update these if you have added/removed new dependency type (e.g. pip) or analysis target type (e.g. poetry).
  • If I made changes to a subcommand's options, I updated docs/references/subcommands/<subcommand>.md.

This PR description was generated with Claude Code

🤖 Generated with Claude Code

https://claude.ai/code/session_019qjHR5TZSM1At5k3XBw7J8


Generated by Claude Code

…fore cleanup

Maven analysis unpacks its depgraph plugin jar into a scratch directory
created under the system temp dir. Cleanup used a hand-rolled
bracket/removeDirRecur that escalated any IO error to a fatal,
analysis-wide error. When the OS temp reaper (or a race) removed the
directory before cleanup ran, the whole run died with:

  An exception occurred: /tmp/fossa-maven-... removeDirectoryRecursive:getSymbolicLinkStatus: does not exist (No such file or directory)

Use withSystemTempDir instead, which removes the scratch directory on a
best-effort basis (ignoring IO errors during cleanup), matching the temp
dir handling used elsewhere in the analyzer.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019qjHR5TZSM1At5k3XBw7J8
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019qjHR5TZSM1At5k3XBw7J8
@fossa-ane-bot
fossa-ane-bot marked this pull request as ready for review September 5, 2026 02:17
@fossa-ane-bot
fossa-ane-bot requested a review from a team as a code owner September 5, 2026 02:17
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Team

Run ID: 1d90bf18-2643-453c-ad14-e18a929c2208

📥 Commits

Reviewing files that changed from the base of the PR and between 57e2ff7 and 3f609ca.

📒 Files selected for processing (3)
  • Changelog.md
  • src/Strategy/Maven/Plugin.hs
  • test/Maven/PluginSpec.hs

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


Walkthrough

withUnpackedPlugin now uses withSystemTempDir for scratch-directory creation and cleanup. Cleanup ignores errors when the directory is already absent. A new test removes the scratch directory before cleanup and verifies that the wrapped computation returns 42. The Maven changelog records this fix.

Merge Risk: ⚪ Minimal · up to 3f609

Maven plugin analysis now tolerates its scratch directory disappearing before cleanup, preventing a cleanup failure from aborting analysis. The regression is covered and no current merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: Maven plugin scratch-directory cleanup now tolerates the directory being removed before cleanup.
Description check ✅ Passed The description is complete and follows the repository template. It explains the intent, acceptance criteria, testing steps, risks, metrics, references, and checklist status.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

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.

2 participants