Repository navigation
Conversation
A rejected value is redacted when its field is a secret, but the type lookup gave up in several cases and then treated the field as not secret. An aliased SecretStr, a secret in a later tuple position, and any field under an optional model or tuple printed the raw value. The lookup now follows aliases, tuple positions and `X | None`, and a path it still can't resolve counts as secret. Errors inside a union member, where pydantic adds the member's name to the path, lose `received`. Refs #87
BREAKING CHANGE: the error document's `fieldErrors` key is now `field_errors`, matching the snake_case keys inside each field error. CommandError builds its report once and no longer copies its fields onto the exception: read them from `error.report`. The report model checks that the code is SCREAMING_CASE, so a bad code still raises ValueError. The private string-errors switch is gone, with the native text it carried. The docs now use `field_errors`. Closes #87
An error on a model, list or tuple reports the whole value as input, so redaction now checks whether the type holds a secret anywhere inside it, not only whether it is one. A model validator that rejects an object with a password, or a too-long list of secrets, no longer prints them. `Secret[T]` and `type` aliases of a secret count as secrets too. Refs #87
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #87
Rejected-input errors could print secret values. Redaction decided whether a field was secret by looking up its type. When the lookup couldn't resolve the type, it treated the field as not secret. It also checked only the type at the error's path, so an error on a model or a list printed every secret inside it.
Now:
X | None. A path it can't resolve counts as secret. Errors inside a union member, where pydantic adds the member's name to the path, losereceived.Secret[T]andtypealiases count too.Breaking changes:
fieldErrorskey is nowfield_errors.CommandErrorno longer hascode,message,retryable,hintandexit_codeattributes. Read them fromerror.report.This also removes a private switch that printed pydantic's and argparse's own error text.