Skip to content

fix: log failed project hard deletes instead of discarding the error - #291

Open
HuiJun wants to merge 1 commit into
developfrom
fix/federated-project-delete-error-message
Open

HuiJun wants to merge 1 commit into
developfrom
fix/federated-project-delete-error-message

Conversation

@HuiJun

@HuiJun HuiJun commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

FederatedProjectPersistence.hardDelete collected failures with message.concat(e.getMessage()). String.concat returns a new string, so message stayed "", the InternalErrorException below it could never be thrown, and a failed database or index delete left no trace at all. Each failure is now logged with its stack trace, and the dead message / throw code is removed.

Fixes SonarCloud issues AaHWUyLo45Pg1SGp66jQ and AaHWUyLo45Pg1SGp66jR (java:S2201, FederatedProjectPersistence.java:104 and :110).

Why it is safe

  • What callers observe is unchanged: before and after, hardDelete attempts both stores and never throws. The only difference is two logger.error calls.
  • New FederatedProjectPersistenceTest covers both stores being deleted, and the index delete still running (without an exception) when the database delete fails. ./gradlew :federatedpersistence:test --tests '*FederatedProjectPersistenceTest' passes.

Not changed, for a maintainer to decide

The original code evidently meant to throw when either delete failed. Doing that now would turn DELETE /projects/{id}?hard=true into a 500 for a partially created project (missing database or index), which is the case ProjectDeleteService allows hard delete for, and would replace the "Could not create project" error in the save cleanup path. This PR keeps the current best-effort behaviour rather than choose that.


Quality Assurance opened this PR for Jason
Implemented in session Get SonarCloud analysis landing for exec-mms
Review with Devin · Open in Devin Desktop


hardDelete collected errors with String.concat, whose result was ignored, so the
message was always empty, nothing was thrown and the failure left no trace.
Keep the best-effort behaviour and log each failure. Fixes Sonar java:S2201.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

projectDAO.delete(projectId);
} catch (Exception e) {
message.concat(e.getMessage());
logger.error("Couldn't delete project {} from the database", projectId, e);
}
if (!message.isEmpty()) {
throw new InternalErrorException(message);
logger.error("Couldn't delete project {} from the index", projectId, e);
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