Skip to content

Internal server error on GET /api/v1/project when portfolio ACL is enabled and excludeInactive parameter is omitted or false #2583

Closed

Description

@nscuro

Current Behavior

Requesting the /api/v1/project endpoint without any query parameters, or with their respective values being false, while portfolio access control is enabled, causes internal server errors. Inspecting the logs reveals:

javax.jdo.JDOUserException: Method/Identifier expected at character 1 in "&& ( accessTeams.contains(:team0) )"
	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.executeWithMap(JDOQuery.java:331)
	at alpine.persistence.AbstractAlpineQueryManager.getCount(AbstractAlpineQueryManager.java:397)
	at alpine.persistence.AbstractAlpineQueryManager.execute(AbstractAlpineQueryManager.java:238)
	at org.dependencytrack.persistence.ProjectQueryManager.getProjects(ProjectQueryManager.java:119)
	at org.dependencytrack.persistence.QueryManager.getProjects(QueryManager.java:338)
	at org.dependencytrack.resources.v1.ProjectResource.getProjects(ProjectResource.java:95)
	...

The issue appears to be a missing non-empty check in the preprocessACLs method:

if (inputFilter != null) {
query.setFilter(inputFilter + " && (" + sb.toString() + ")");
} else {
query.setFilter(sb.toString());
}

This issue mostly affects API clients, as the frontend always sets request query parameters, and excludeInactive and onlyRoot default to true for it.

Steps to Reproduce

  1. Enable Portfolio Access Control in the settings
  2. Get an API key
  3. Request the /api/v1/project endpoint without any parameters
curl -v -H 'X-Api-Key: <API_KEY>' 'http://localhost:8080/api/v1/project'

Expected Behavior

Querying projects should not fail when no request query parameters are set.

Dependency-Track Version

4.8.0-SNAPSHOT

Dependency-Track Distribution

Container Image, Executable WAR

Database Server

N/A

Database Server Version

No response

Browser

N/A

Checklist

Activity

  1. added
    defect
    on Mar 9, 2023
  2. added this to the 4.8 milestone on Mar 9, 2023
  3. added 2 commits that reference this issue on Mar 9, 2023
    ce97efb
    ca74c26
  4. tomkuipers commented on Mar 13, 2023

    @tomkuipers

    Any updates about an upcoming release containing this specific fix? Our pipelines fail because of this issue when using mvn plugin https://github.com/pmckeown/dependency-track-maven-plugin

  5. added a commit that references this issue on Mar 24, 2023
    b7d98df
  6. added 2 commits that reference this issue on Apr 6, 2023
    c4e2474
    1802a8c
  7. github-actions commented on Apr 15, 2023

    @github-actions
    Contributor

    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.

  8. locked as resolved and limited conversation to collaborators on Apr 15, 2023
  9. added a commit that references this issue on Jun 17, 2026
    79561e9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    access controldefect

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions