Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with importing new BOMs #3957

Closed
2 tasks done
j4care-christianhahn opened this issue Jul 9, 2024 · 11 comments · Fixed by #3958
Closed
2 tasks done

Problem with importing new BOMs #3957

j4care-christianhahn opened this issue Jul 9, 2024 · 11 comments · Fixed by #3958
Labels
defect Something isn't working p2 Non-critical bugs, and features that help organizations to identify and reduce risk size/S Small effort
Milestone

Comments

@j4care-christianhahn
Copy link

Current Behavior

when I build my projects on jenkins I currently use the API of Dependency Track to import the BOMs and create new projects for each version which worked great for the past months.
Now I suddenly get the following exception with 2 projects:

2024-07-09 13:15:43,664 INFO [BomUploadProcessingTask] Processing CycloneDX BOM uploaded to project: 361da822-885a-4ba3-915c-63c6280fd460
2024-07-09 13:15:45,199 ERROR [BomUploadProcessingTask] Error while processing bom
javax.jdo.JDOUserException: The query returned more than one instance BUT either unique is set to true or only aggregates are to be returned, so should have returned one result maximum
at org.datanucleus.api.jdo.JDOAdapter.getJDOExceptionForNucleusException(JDOAdapter.java:698)
at org.datanucleus.api.jdo.JDOQuery.executeInternal(JDOQuery.java:456)
at org.datanucleus.api.jdo.JDOQuery.executeUnique(JDOQuery.java:360)
at org.dependencytrack.persistence.LicenseQueryManager.getLicenseByIdOrName(LicenseQueryManager.java:102)
at org.dependencytrack.persistence.QueryManager.getLicenseByIdOrName(QueryManager.java:624)
at org.dependencytrack.parser.cyclonedx.util.ModelConverter.convert(ModelConverter.java:574)
at org.dependencytrack.parser.cyclonedx.util.ModelConverter.convertComponents(ModelConverter.java:464)
at org.dependencytrack.tasks.BomUploadProcessingTask.inform(BomUploadProcessingTask.java:157)
at org.dependencytrack.tasks.BomUploadProcessingTaskV2.inform(BomUploadProcessingTaskV2.java:151)
at alpine.event.framework.BaseEventService.lambda$publish$0(BaseEventService.java:110)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: org.datanucleus.store.query.QueryNotUniqueException: The query returned more than one instance BUT either unique is set to true or only aggregates are to be returned, so should have returned one result maximum
at org.datanucleus.store.query.Query.executeQuery(Query.java:2039)
at org.datanucleus.store.query.Query.executeWithMap(Query.java:1911)
at org.datanucleus.api.jdo.JDOQuery.executeInternal(JDOQuery.java:437)
... 11 common frames omitted

Steps to Reproduce

1.build 2 of my projects to get the exception

Expected Behavior

Process the BOM

Dependency-Track Version

4.11.5

Dependency-Track Distribution

Container Image

Database Server

PostgreSQL

Database Server Version

14

Browser

Google Chrome

Checklist

@j4care-christianhahn j4care-christianhahn added defect Something isn't working in triage labels Jul 9, 2024
@nscuro
Copy link
Member

nscuro commented Jul 9, 2024

Did you create custom licenses that have names which overlap with SPDX licenses?

@j4care-christianhahn
Copy link
Author

not that I would be aware of - how could I check that ?

@j4care-christianhahn
Copy link
Author

seems like there are some double entries in the DB which I didn't create:

select "NAME",count("NAME") from "LICENSE" group by "NAME";

GNU General Public License v1.0 only | 2
GNU General Public License v1.0 or later | 2
GNU General Public License v2.0 only | 2
GNU General Public License v2.0 or later | 2
GNU General Public License v3.0 only | 2
GNU General Public License v3.0 or later | 2
GNU Lesser General Public License v2.1 only | 2
GNU Lesser General Public License v2.1 or later | 2
GNU Lesser General Public License v3.0 only | 2
GNU Lesser General Public License v3.0 or later | 2
GNU Library General Public License v2 only | 2
GNU Library General Public License v2 or later | 2

@j4care-christianhahn
Copy link
Author

Doesn't seam that there are some custom licenses declared:

dtrack=# select count(*) from "LICENSE" where "ISCUSTOMLICENSE" = true;
count

 0

How can I clean up the licenses ?

@nscuro
Copy link
Member

nscuro commented Jul 9, 2024

seems like there are some double entries in the DB which I didn't create:

How does it look when you take LICENSE_ID into consideration? Are there still dupes?

@j4care-christianhahn
Copy link
Author

no they are all unique.

@nscuro
Copy link
Member

nscuro commented Jul 9, 2024

I think this needs a code change then. The query should not fail when multiple results are returned, instead it should just take the first and proceed with that.

You can try to delete the dupes, but ultimately they will likely be recreated when the API server is restarted. If the ID is different then they are legitimately different licenses.

@nscuro nscuro added p2 Non-critical bugs, and features that help organizations to identify and reduce risk size/S Small effort and removed pending more information labels Jul 9, 2024
@nscuro nscuro added this to the 4.12 milestone Jul 9, 2024
@j4care-christianhahn
Copy link
Author

can I somehow debug the SQL statement that gets executed to check which license id is causing the issue ?

@j4care-christianhahn
Copy link
Author

or can I somehow just "delete" the licenses so that they get recreated somehow as I cannot continue to work with my projects for the moment ?

@nscuro
Copy link
Member

nscuro commented Jul 9, 2024

Non-custom licenses are usually not intended to be deleted by users so neither UI nor REST API have functionality for that. You could delete them via SQL. But again, the API server will re-create all licenses from the SPDX license list upon every restart.

@nscuro nscuro closed this as completed in 3bfbd1d Jul 9, 2024
nscuro added a commit to nscuro/dependency-track that referenced this issue Aug 7, 2024
…ense name

Fixes DependencyTrack#3957

Signed-off-by: nscuro <nscuro@protonmail.com>
nscuro added a commit to nscuro/dependency-track that referenced this issue Aug 7, 2024
…ense name

Fixes DependencyTrack#3957

Signed-off-by: nscuro <nscuro@protonmail.com>
nscuro added a commit to nscuro/dependency-track that referenced this issue Aug 7, 2024
…ense name

Fixes DependencyTrack#3957

Signed-off-by: nscuro <nscuro@protonmail.com>
netomi pushed a commit to netomi/dependency-track that referenced this issue Aug 8, 2024
…ense name

Fixes DependencyTrack#3957

Signed-off-by: nscuro <nscuro@protonmail.com>
Copy link
Contributor

github-actions bot commented Aug 9, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 9, 2024
@nscuro nscuro modified the milestones: 4.12, 4.11.6 Aug 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
defect Something isn't working p2 Non-critical bugs, and features that help organizations to identify and reduce risk size/S Small effort
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants