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

Validate API input #2476

Closed
2 tasks done
valentijnscholten opened this issue Feb 9, 2023 · 3 comments
Closed
2 tasks done

Validate API input #2476

valentijnscholten opened this issue Feb 9, 2023 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@valentijnscholten
Copy link
Contributor

valentijnscholten commented Feb 9, 2023

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

  • validate input fields like uuid for having the correct format
  • supply validation errors (4xx) to the client in case of errors
  • ideally log some info about what is wrong (without exposing too much internal/sensitive details)

Checklist

@valentijnscholten valentijnscholten added the enhancement New feature or request label Feb 9, 2023
@nscuro
Copy link
Member

nscuro commented Feb 9, 2023

The suggestion I posted in #840 (comment) 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 nscuro added this to the 4.11 milestone May 18, 2024
@nscuro
Copy link
Member

nscuro commented May 18, 2024

Should be fixed in v4.11 via #3590, #3590, and #3659

@nscuro nscuro closed this as completed May 18, 2024
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 Jun 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants