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

Omit input data from validation errors #120

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

ada-globus
Copy link
Contributor

@ada-globus ada-globus commented Jan 23, 2024

Additionally, ensure that these errors only produce string descriptions, allowing us to normalize error shapes. Further still, adopt HTTP response status code 422 for errors where input is parsable but in an invalid form.

(n.b., in addition to the previously discussed python-jsonschema error messages, this also addresses error dicts emitted by Pydantic, which also include input data.)

I tried to keep this quite narrow, though given that validation errors appear to be the only source of non-string error descriptions, I took the adjacent opportunity to simplify the base error model at the same time.

Note that one of the example APs ("whattimeisit") returns errors in a completely different format from the classes we provide. As such, I did not address it here. Open to continuing to noodle on the validation error messaging if anyone has ideas for simple, obvious improvements.

I'm considering whether additional tests are warranted as this handling appears to be somewhat under-exercised.

Updating APs to use this release should allow validation errors to appear correctly in Flows event logs, as the error parsing performed by the Globus Python SDK will begin to recognize these error messages once description is a string.

Additionally, ensure that these errors only produce string
descriptions, allowing us to normalize error shapes.

Further, adopt HTTP response status code 422 for errors where input
is parsable but in an invalid form.

Signed-off-by: Ada <[email protected]>
Copy link
Member

@sirosen sirosen left a comment

Choose a reason for hiding this comment

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

Seeing this reminds me that I don't like that this repo, which is meant to be a library, is using pydantic. It means we're stuck in the pydantic v1 vs v2 situation which is a whole mess of its own.

One thing we didn't talk about is that the SDK is actually capable of parsing multiple messages from a response, which we introduced as part of the JSON:API support path. But it would require that the errors are reshaped in a rather explicit and specific way. We can circle back on that in the future if we want.

@ada-globus
Copy link
Contributor Author

One thing we didn't talk about is that the SDK is actually capable of parsing multiple messages from a response, which we introduced as part of the JSON:API support path. But it would require that the errors are reshaped in a rather explicit and specific way. We can circle back on that in the future if we want.

💯

This thought occurred to me, too, while I was making sure I'd gone over all of the potential error shapes. Rather ironically, I think the included example AP that does not use the error functionality provided by this package and instead omits a completely different error shape is much closer to the format we'd want in order to handle multiple messages. If we were to move to something like that, though, we'll want to publish a proper error schema and support both paths temporarily... So hopefully with this change that is now a next adjacent move that's newly available to us? 😄

@ada-globus
Copy link
Contributor Author

Seeing this reminds me that I don't like that this repo, which is meant to be a library, is using pydantic. It means we're stuck in the pydantic v1 vs v2 situation which is a whole mess of its own.

Also, yes, agree—would prefer to see this move away from a framework and more to a collection of, well... tools. 😉

@ada-globus ada-globus merged commit c7a33b2 into main Jan 24, 2024
13 checks passed
@ada-globus ada-globus deleted the an/fix_error_description_field_behavior branch January 24, 2024 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants