DependencyTrack / dependency-track

Dependency-Track is an intelligent Component Analysis platform that allows organizations to identify and reduce risk in the software supply chain.
https://dependencytrack.org/
Apache License 2.0
2.59k stars 543 forks source link

Validate API input #2476

Closed valentijnscholten closed 4 months ago

valentijnscholten commented 1 year ago

Current Behavior

My log is full of these logs:

2023-02-06 09:30:42,873 ERROR [GlobalExceptionHandler] Uncaught internal server error
                  java.lang.IllegalArgumentException: Invalid UUID string:  
                  java.base/java.util.UUID.fromString1(Unknown Source)
                  java.base/java.util.UUID.fromString(Unknown Source)
                  alpine.persistence.AbstractAlpineQueryManager.getObjectByUuid(AbstractAlpineQueryManager.java:563)
                  org.dependencytrack.resources.v1.BomResource.uploadBom(BomResource.java:259)
                  jdk.internal.reflect.GeneratedMethodAccessor199.invoke(Unknown Source)
                  java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                  java.base/java.lang.reflect.Method.invoke(Unknown Source)

Of course this is clearly a mistake by the user/client, but this shouldn't result in a 500 error and also not in log messages at ERROR level. The response to the client is Uncaught internal server error, which doesn't help the client.

Proposed Behavior

Checklist

nscuro commented 1 year ago

The suggestion I posted in https://github.com/DependencyTrack/dependency-track/issues/840#issuecomment-1146358660 somewhat fits into this.

If we could define requests and their formats in the OpenAPI spec, the generated code would also have syntactic validation.

nscuro commented 4 months ago

Should be fixed in v4.11 via https://github.com/DependencyTrack/dependency-track/pull/3590, https://github.com/DependencyTrack/dependency-track/pull/3590, and https://github.com/DependencyTrack/dependency-track/pull/3659

github-actions[bot] commented 3 months ago

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.