Skip to content

fix(fossology): rollback clearingState when upload preparation fails#4037

Open
Aman-Cool wants to merge 2 commits intoeclipse-sw360:mainfrom
Aman-Cool:fix/fossology-clearing-state-rollback
Open

fix(fossology): rollback clearingState when upload preparation fails#4037
Aman-Cool wants to merge 2 commits intoeclipse-sw360:mainfrom
Aman-Cool:fix/fossology-clearing-state-rollback

Conversation

@Aman-Cool
Copy link
Copy Markdown
Contributor

When triggering a FOSSology upload, the handler marks the release as SENT_TO_CLEARING_TOOL in CouchDB before it actually tries to fetch the attachment and upload it. If anything goes wrong during that prep work (missing attachment content, transient DB error, etc.), the exception just bubbles up and the clearing state never gets reset; leaving the release permanently stuck with no way to re-trigger from the UI.

This fix wraps the risky part in a try-catch so that on any failure, we reset the step back to NEW and write NEW_CLEARING back to the document before re-throwing, the same cleanup that already happens on a normal upload failure response.

Issue: NA

Suggest Reviewer

@GMishx

How To Test?

  1. Create a release with a source attachment, then delete the attachment content document directly from CouchDB (simulating a stale reference or failed upload).
  2. Trigger FOSSology from the release page.
  3. Before fix: the release gets stuck at SENT_TO_CLEARING_TOOL even though nothing was sent. Re-triggering is blocked.
  4. After fix: the release returns to NEW_CLEARING and you can retry once the attachment issue is resolved.

No new tests added; the existing FOSSology handler tests cover the upload step; manual reproduction is straightforward with a CouchDB document edit.

Checklist

Must:

  • All related issues are referenced in commit messages and in PR

@Aman-Cool Aman-Cool marked this pull request as ready for review April 6, 2026 06:09
@Aman-Cool
Copy link
Copy Markdown
Contributor Author

Hey @GMishx, found a bug where a FOSSology trigger failure leaves the release permanently stuck at SENT_TO_CLEARING_TOOL with no way to retry from the UI. Fix just adds a rollback for the cases that were slipping through. Pretty small change, let me know if anything looks off!

Copy link
Copy Markdown
Contributor

@Sandipmandal25 Sandipmandal25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just one concern about exception handling added a comment below

@Aman-Cool
Copy link
Copy Markdown
Contributor Author

@Sandipmandal25, Wrapped the rollback call in its own try-catch so if CouchDB is also down, the rollback failure gets logged but swallowed and the original exception always propagates cleanly.

@Aman-Cool Aman-Cool requested a review from Sandipmandal25 April 6, 2026 09:01
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