jenkinsci/dependency-track-plugin

Fails if Dependencey Track API server returns Not Modified

HagarJNode opened this issue · 3 comments

Describe the bug

If one has projects that with no modifications the API server will respond with a http status 304 when calling patchProject in the ProjectResource. The ApiClient updateProject in this plugin fails when the respons is not 200 and blocks builds when it happens.

Environment

  • Plugin Version: 4.76
  • Jenkins Version: 2.426.2
  • Java Version for Jenkins: 17.0.9
  • Type of Jenkins Job: declarative pipeline
  • Dependency-Track Version: 4.10.0

Expected behavior

Should accept getting 304 as well as 200.

Additional context

10:59:59.558 Also: org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 0534db0c-5720-4d62-98db-2437527c2419
10:59:59.558 org.jenkinsci.plugins.DependencyTrack.ApiClientException: An error occurred while updating project with id "1d6e9e71-8f91-4892-8116-6723cd53cdee" - HTTP response code: 304 Not Modified

I could surely create a fix and a pull request to fix this, but I already have this #122 and nothing has happened - no feedback, so I'm not sure that help is welcomed.

Work around:
Add tags to the projectProperties, as there is a bug in the API server that checks for modifications in collections of a project.

First of all, there is no version 4.76 of this plugin.

The status code 304 is only used in the PATCH variant, which is only used in the current, unreleased development version of the plugin. The status code is also not documented in the API description. In addition, the status 304 is used incorrectly here. The code is intended for GET and HEAD and only if it is a conditional request. However, I understand why it is used in this case and will adjust it in the plugin.

Sorry, I wrote the org.jenkins-ci.plugins version instead of the version of the plugin - my fault.

Yes, I noted that the documentation of Dependency Track didn't have all the respons codes, as I was searching for the reason for the fail.

I agree on your point of the 304 shouldn't have been used in the PATCH request, but am glad that you're taking care of it in the plugin.

No problem, thanks for the tip.