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

Unrecognized field "parentUuid" in Project #2439

Closed
2 tasks done
sephiroth-j opened this issue Feb 2, 2023 · 6 comments · Fixed by #2470
Closed
2 tasks done

Unrecognized field "parentUuid" in Project #2439

sephiroth-j opened this issue Feb 2, 2023 · 6 comments · Fixed by #2470
Labels
defect Something isn't working
Milestone

Comments

@sephiroth-j
Copy link
Contributor

Current Behavior

The JSON representation of a project contains the field "parentUuid" which is not consumable by other operations that consume a project.

@JsonProperty("parentUuid")
private UUID getParentUuid() {
return (this.getParent() == null) ? null : this.getParent().getUuid();
}

If you send a request with that field to /api/v1/project, you will get the following response with code 400 (bad request).

Unrecognized field "parentUuid" (class org.dependencytrack.model.Project), not marked as ignorable (22 known properties: "classifier", "metrics", "lastBomImportFormat", "parent", "author", "lastBomImport", "directDependencies", "properties", "swidTagId", "version", "tags", "uuid", "publisher", "group", "active", "name", "externalReferences", "cpe", "description", "purl", "children", "lastInheritedRiskScore"]) at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 4480] (through reference chain: org.dependencytrack.model.Project["parentUuid"])

Steps to Reproduce

  1. create two projects a and b
  2. define project a to be the parent of b
  3. retrieve project b using GET /api/v1/project/<uuid of b>
  4. POST the response from step 1 back to /api/v1/project

Expected Behavior

The "parentUuid" field should not be part of the project model. It is not needed at all because it has the same value as "uuid" of the "parent" field. Either remove it completely or at least mark it as ignorable.

Dependency-Track Version

4.7.1

Dependency-Track Distribution

Container Image

Database Server

PostgreSQL

Database Server Version

No response

Browser

N/A

Checklist

@sephiroth-j sephiroth-j added defect Something isn't working in triage labels Feb 2, 2023
sephiroth-j added a commit to jenkinsci/dependency-track-plugin that referenced this issue Feb 2, 2023
@sephiroth-j
Copy link
Contributor Author

@rbt-mm
Copy link
Contributor

rbt-mm commented Feb 6, 2023

The parentUuid field cannot be removed, because it is necessary for displaying the parent-child relationships in the frontend project list.

The treegrid plugin, which is used for the hierarchical project view, needs an idField and a parentIdField to correctly display those relationships.
Unfortunately, neither of those fields can be a nested property (like parent.uuid), so during serialization it is necessary to add a field to a Project object that directly references its parent project (like parentUuid does) to avoid this limitation.

https://github.com/DependencyTrack/frontend/blob/b30414d77eef7df5cd357ba54bc01e6f3ff0c307/src/views/portfolio/projects/ProjectList.vue#L266-L267

I guess the best solution would be to somehow ignore this field during de-serialization, so that the project list in the frontend still displays the relationships correctly.

@sephiroth-j
Copy link
Contributor Author

This is a pure frontend problem which should (and can) be solved there without changing the API. Instead, however, the model in the API was changed in a way that the API itself can't handle!

So, instead of this

project.pid = MurmurHash2(project.parentUuid).result()

Why not just this?

project.pid = MurmurHash2(project.parent?.uuid).result()

@rbt-mm
Copy link
Contributor

rbt-mm commented Feb 7, 2023

So, instead of this
project.pid = MurmurHash2(project.parentUuid).result()
Why not just this?
project.pid = MurmurHash2(project.parent?.uuid).result()

Well, for some reason I didn't think about such a simple solution 😅.

Thanks for noticing, if you want I can create a PR for this fix tomorrow.

@sephiroth-j
Copy link
Contributor Author

Please do so, because I won't have time to do so in the next few days.

@github-actions
Copy link
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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
defect Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants