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

Fix NullPointerException when updating a project #2319

Conversation

rbt-mm
Copy link
Contributor

@rbt-mm rbt-mm commented Dec 20, 2022

Description

If the active status of a project is null and someone tries to update that project, a NullPointerException will be thrown because that case is currently not handled.

This PR checks if the active status of a project is null when trying to update the project, and handles the case, resulting in no NullPointerException being thrown.

Addressed Issue

Closes #2317

Checklist

  • I have read and understand the contributing guidelines
  • This PR fixes a defect, and I have provided tests to verify that the fix is effective
    - [ ] This PR implements an enhancement, and I have provided tests to verify that it works as intended
    - [ ] This PR introduces changes to the database model, and I have added corresponding update logic
    - [ ] This PR introduces new or alters existing behavior, and I have updated the documentation accordingly

Fixes the `NullPointerException` which occurs when updating a project
where `project.isActive() == null`

Signed-off-by: RBickert <[email protected]>
@valentijnscholten
Copy link
Contributor

if you run a project wide search for isActive() there are 2 or 3 other places which could do with the same safeguard.

@rbt-mm
Copy link
Contributor Author

rbt-mm commented Dec 21, 2022

Thanks for noticing, I think that every isActive() should be handled correctly now.

Copy link
Member

@nscuro nscuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rbt-mm and @valentijnscholten! 🙌

@nscuro nscuro merged commit a160bd5 into DependencyTrack:master Dec 21, 2022
mulder999 pushed a commit to mulder999/dependency-track that referenced this pull request Dec 23, 2022
)

* Fix `NullPointerException` in ProjectQueryManager

Fixes the `NullPointerException` which occurs when updating a project
where `project.isActive() == null`

Signed-off-by: RBickert <[email protected]>

* Prevent NullPointerException in NotificationRouter

Signed-off-by: RBickert <[email protected]>

Signed-off-by: RBickert <[email protected]>
Signed-off-by: mulder999 <[email protected]>
@valentijnscholten
Copy link
Contributor

valentijnscholten commented Jan 17, 2023

@nscuro This started occurring out of nowhere on my instances. There might be some codepaths in 4.7.0 that somehow set a null value in the database. So a onetime SQL query to fix those values might not be a structural solution. Any chance we can get a 4.7.1? I can whip up a PR with backport + release notes.

@nscuro
Copy link
Member

nscuro commented Jan 18, 2023

@valentijnscholten We're looking into bundling multiple of such annoyances into a bugfix release right now. I've seen a few similar requests now on other issues so I think it makes sense to backport more than just this.

@SaberStrat
Copy link

Any update on a patch release to help fix this?
I'm doing a POST on the project API in several places in our CI, and this is failing now :/. Is there any workaround that I could attempt until then? A manual SQL query against the table with the missing active values?

nscuro pushed a commit to nscuro/dependency-track that referenced this pull request Jan 31, 2023
)

* Fix `NullPointerException` in ProjectQueryManager

Fixes the `NullPointerException` which occurs when updating a project
where `project.isActive() == null`

Signed-off-by: RBickert <[email protected]>

* Prevent NullPointerException in NotificationRouter

Signed-off-by: RBickert <[email protected]>

Signed-off-by: RBickert <[email protected]>
@nscuro
Copy link
Member

nscuro commented Jan 31, 2023

We backported this to 4.7.1, which was just released.

@SaberStrat
Copy link

Thank you very much ❤️

stephan-wolf-ais pushed a commit to AISAutomation/dependency-track that referenced this pull request Mar 1, 2023
)

* Fix `NullPointerException` in ProjectQueryManager

Fixes the `NullPointerException` which occurs when updating a project
where `project.isActive() == null`

Signed-off-by: RBickert <[email protected]>

* Prevent NullPointerException in NotificationRouter

Signed-off-by: RBickert <[email protected]>

Signed-off-by: RBickert <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Updating a project fails when its active status is null
4 participants