[ANE-Bot] Tolerate Maven plugin scratch dir removed before cleanup - #1771
[ANE-Bot] Tolerate Maven plugin scratch dir removed before cleanup#1771fossa-ane-bot wants to merge 2 commits into
Conversation
…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
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. Walkthrough
Merge Risk: ⚪ Minimal · up to 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)
Comment |
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-rolledbracket/removeDirRecurpair 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: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
withUnpackedPluginwithwithSystemTempDir, which removes the scratch directory on a best-effort basis (it routes cleanup throughpath-io, which ignores IO errors during removal). This matches how every other temp directory in the analyzer is handled — including the immediately-followingwithSystemTempDir "fossa-depgraph"call in the sameanalyzefunction.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
cabal build(ormake build-cli).cabal test unit-tests --test-options='--match "withUnpackedPlugin"'. The new case invokeswithUnpackedPluginand deletes the scratch directory from inside the callback, then asserts the call still returns normally. Against the previous cleanup code this case fails with theremoveDirectoryRecursiveexception; with the fix it passes.fossa analyzeagainst 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
withSystemTempDirhelper 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
docs/.docs/README.msand gave consideration to how discoverable or not my documentation is.Changelog.md. If this PR did not mark a release, I added my changes into an## Unreleasedsection at the top..fossa.ymlorfossa-deps.{json.yml}, I updateddocs/references/files/*.schema.jsonAND I have updated example files used byfossa initcommand. 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).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