-
Notifications
You must be signed in to change notification settings - Fork 43
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
SafeLoggable exception for invalid UUID values #2212
base: develop
Are you sure you want to change the base?
Conversation
Generate changelog in
|
@ash211 I'm not sure this should be necessary/worth the additional generated exception handling. In the worst case, the stack trace points to the point in the jdk uuid parser which throws the error, making it clear what the cause was. Not the best devx, but workable. |
Ah, I misread the problem you're solving -- not that the exception isn't safeloggable, but that we don't have a way to understand the bad input. |
Sorry, I should've made the PR title/description more clear. You're right that I'm trying to solve "what was the invalid input?" and not "the thrown exception doesn't inherit from SafeLoggable" Being able to promote UnsafeArgs to SafeArgs where possible would be a nice extension! In the particular case that prompted this the user had access to unsafe logs (on an IL), but I acknowledge that's not the common case. In the meantime, I was thinking it's safe to log at UnsafeArg level, since that's what Maybe we can use the conjure log-safety context (not entirely sure what that is) to improve both |
@ash211 The computed/combined log-safety is evaluated here: https://github.com/palantir/conjure-java/blob/2ad5a433bf2355461253a0888ce7eccc27ec7cd3/conjure-java-core/src/main/java/com/palantir/conjure/java/types/AliasGenerator.java#L76C29-L76C43 It's used to set the type-level safety annotations on the class.
I think that may be a bit questionable, though probably fine in practice because resource-id has a more specific intent than uuid. If we go down this path, I think we should attempt to solve both Alias.valueOf(String) (for all aliases which produce such a method, not exclusively UUID), and the PlainSerDe deserializers for header/query/path params. I'm not sure we can do anything quite as helpful for jackson deserialization, but it's a start. |
Before this PR
Parsing a too-long UUID string fails with an IllegalArgumentException which does not include the invalid value:
openjdk/jdk source
See https://pl.ntr/2l6 for an internal example stacktrace.
This makes it difficult to debug, as there is no log of the value, even at unsafe level, to assist with debugging.
After this PR
==COMMIT_MSG==
SafeLoggable exception for invalid UUID values
==COMMIT_MSG==
Possible downsides?
Potentially there is some performance impact from this change for parsing invalid UUID aliases, or even valid UUIDs. I think it's likely slight -- just wrapped in a try block for the valid case, and creating a wrapping exception for the invalid case.