Incorrect API response from GET /api/v1/project/{id} following a specific sequence of API calls #3883
Closed
2 tasks done
Labels
Milestone
Current Behavior
Dependency-Track returns an incorrect response body when creating and reading a project with a parent via the API with the following sequence of calls:
PUT /api/v1/project
to create a parent project (that itself has no parent)PUT /api/v1/project
to create a child project (that has the project from step 1 as its parent)GET /api/v1/project/{parentId}
GET /api/v1/project/{childId}
In this sequence the response from step (3) correctly identifies the child in the
children
field (responses prettified for readibility):But the response from (4) contains a malformed field
"parent":{}
instead of a reference to the parent:The ordering of calls is important. Exchanging the order of steps (3) and (4) (i.e. getting the child after its created before getting its parent) fixes this problem, apparently for all subsequent calls like (4).
We've also noticed another effect: the GET parent project response has no
parent
field at all before the child is created. But after the child is created the response contains a correctly formedparent
field pointing back to the parent. We're not sure whether this is a second defect (and which of the two ways is correct), or by design.Steps to Reproduce
This was tested on a dockerized DT started from a docker compose file consistent with https://dependencytrack.org/docker-compose.yml (no changes to the configuration of those two containers).
cause-bug.sh.gz
Expected Behavior
Responses from
GET /api/v1/project/{projectId}
should correctly identify the parent project or lack thereof regardless of API call order.Dependency-Track Version
4.11.4
Dependency-Track Distribution
Container Image
Database Server
N/A
Database Server Version
No response
Browser
N/A
Checklist
The text was updated successfully, but these errors were encountered: