-
Notifications
You must be signed in to change notification settings - Fork 21
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
🐛 Fixed missing models field not skipping serialization on GuardrailsConfig #99
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! I don’t think this is quite the behavior we want to resolve the JSON deserialization error, since we ultimately still want to give the user an error showing that models
is a required field.
I think the update I would expect is for an update of deserialization, since I would expect the same error “Failed to deserialize…” to still surface if any other required inputs are left off, but we want those errors to give a clear error in code/details like the other errors.
It sounds like the objective is to:
Axum features a Json extractor that handles deserializing/serializing the requests/responses via serde behind the scenes. When deserialization fails, it returns a JsonRejection error. In the case of a missing field, the What we need to do is map this to I went ahead and gave this a try here. The error message returned for a missing field is now: {
"code": 422,
"details": "guardrail_config.input: missing field `models` at line 6 column 3"
} If this is sufficient, feel free to steal this. If the message needs to be customized further, it will be a more complicated task. You may be able to downcast Btw, here is a thread with some useful information for reference. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of requested changes:
- Rebase latest changes from main
- You can drop
ValidationError::Missing
variant as it isn't being used
…Config Input/Output Signed-off-by: Paulo Caldeira <[email protected]>
…ation (foundation-model-stack#91) Signed-off-by: Paulo Caldeira <[email protected]>
…tom code/details error (suggested by declark1) Signed-off-by: Paulo Caldeira <[email protected]>
Signed-off-by: Paulo Caldeira <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Since Evaline is out and these changes should also address her comments, will approve and merge.
This PR addresses #91, solved by (edit) adding validation to
models
field.Added a test case regarding the issue as well.