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

Serialize model with SecretStr #919

Closed
ashears opened this issue Oct 21, 2019 · 3 comments
Closed

Serialize model with SecretStr #919

ashears opened this issue Oct 21, 2019 · 3 comments
Labels

Comments

@ashears
Copy link
Contributor

ashears commented Oct 21, 2019

Question

I would like to call .dict() method on a model with a secret str type.

The use case is that I want to log this model with the secret still hidden, but need to send the payload with it as the true string.

Currently, I get: TypeError: Object of type SecretStr is not JSON serializable

Is there a function that can be called on a model with SecretStr type that will turn it into a dictionary with the Secrets visible?

Environment:
pydantic: 0.32.2
OS: macOS
python: 3.7.0

@samuelcolvin
Copy link
Member

samuelcolvin commented Oct 21, 2019 via email

@ashears
Copy link
Contributor Author

ashears commented Oct 21, 2019

Apologies for not including, added to the orginal post

@ashears
Copy link
Contributor Author

ashears commented Oct 22, 2019

After reading this thread: #133, I realize the way I was intending to use it was incorrect and the thread had examples to solve my use case. Closing this issue.

@ashears ashears closed this as completed Oct 22, 2019
alexdrydew pushed a commit to alexdrydew/pydantic that referenced this issue Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants