fix(projects): prevent data corruption and crashes in attachment usage inheritance#3773
Open
Aman-Cool wants to merge 1 commit intoeclipse-sw360:mainfrom
Open
fix(projects): prevent data corruption and crashes in attachment usage inheritance#3773Aman-Cool wants to merge 1 commit intoeclipse-sw360:mainfrom
Aman-Cool wants to merge 1 commit intoeclipse-sw360:mainfrom
Conversation
…on in sub-project inheritance
Contributor
Author
|
@GMishx @amritkv, Fixed three bugs in attachment usage inheritance:
Let me know if you need any changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes three critical bugs in attachment usage inheritance that cause data corruption, service crashes, and compliance violations. When
INHERIT_ATTACHMENT_USAGESis enabled, projects with component-level attachments write corrupted data to CouchDB, deleted sub-projects cause NullPointerException, and circular project references trigger StackOverflowError that kills service threads.The primary bug:
parseAttachmentUsages()incorrectly assumes all attachment owners are releases. Thrift'sSourceunion can also be components or projects, but callinggetReleaseId()on a non-release Source silently returns null. This null gets written to CouchDB asSource.releaseId(null), corrupting AttachmentUsage documents and breaking downstream license report generation.Related Issue
N/A
Changes Made
1. Null owner corruption fix (parseAttachmentUsages - primary bug)
isSetReleaseId()check before accessing release ID from Thrift Source union2. NPE fix (buildProjectPaths - deleted sub-projects)
repository.get()result3. StackOverflowError fix (buildProjectPaths - circular references)
Set<String> visitedparametergetReleaseIdsOfProjectTree()in same fileFile changed:
backend/common/src/main/java/org/eclipse/sw360/datahandler/db/ProjectDatabaseHandler.java(~15 lines)Testing
Impact
Checklist
git commit -s)fix(projects): prevent data corruption and crashes in attachment usage inheritanceAdditional Notes
This commit fixes three related bugs in the attachment usage inheritance feature:
Primary bug: Thrift Source union type safety issue - Apache Thrift's Java code generation allows calling
getReleaseId()on a Source union whose active field iscomponentIdorprojectId, silently returning null instead of throwing an error. The correct API (isSetReleaseId()) exists but wasn't used. This demonstrates a key challenge the Thrift migration project aims to solve - with sealed interfaces or discriminated unions in pure Java/Spring, this would be a compile-time error.Secondary bugs: Missing defensive checks - both the null guard and cycle detection follow patterns already established in
getReleaseIdsOfProjectTree()in the same file, but were omitted in the new code.Production impact: Silent data corruption in compliance-critical license documents, service crashes from NPE, and thread pool exhaustion from StackOverflowError.