Closed MaelAbgrall closed 2 years ago
I can't reproduce your issue. I'm unsure what's happening, but my guess is that it should be related to the open()
of the .env
file.
In any case, can you do the same check with this snippet i.e. using Environ
?
from starlette.datastructures import Secret
from starlette.config import Config, Environ
config = Config(environ=Environ({"SECRET": "mystring"}))
SECRET = config("SECRET", cast=Secret)
Hello, My apologies, I did not realise that docker restart was not updating the environment variables, and I originally stored as a Byte string.
When starting my setup this morning, the env has been updated to the new string (not byte) and all is fine!
Thank you for the quick reply
Checklist
master
.Describe the bug
Hello! I'm using Starlette through FastAPI (latest), and I'm having some trouble with configuration files.
Starlette's Config secret is converting a string into a Bytes type. The problem is since I need to cast this secret to a string to access it, it creates a strange data structure.
I am trying to save in secrets a Fernet key from the cryptography pipy library. My goal is to encrypt data saved in a database. However, as you can see in the examples, I'm unable to convert back this key into a type that can be read by cryptography
Steps to reproduce the bug
requirements.txt
.env
Python interactive shell
Expected behavior
Either:
Actual behavior
Secrets have an unknown type, that can't be encoded or used
Debugging material
see "Steps to reproduce bug"
Environment
Additional context
No response