Hey, we're running Prefect 3.0.3 in production and...
# ask-community
n
Hey, we're running Prefect 3.0.3 in production and are trying to upgrade to 3.1.11. Unfortunately, the recent refactoring of how Settings are being handled is giving us a lot of headaches as it seems to have introduced a weird bug or two. The following docker-compose entry
Copy code
prefect-server:
    image: prefecthq/prefect:3.1.11-python3.12
    command: ["prefect", "server", "start"]
    container_name: prefect-server
    depends_on:
      prefect-database:
        condition: service_healthy
    ports:
      - "4200:4200"
    environment:
      - PREFECT_SERVER_API_HOST=0.0.0.0
      - PREFECT_SERVER_API_PORT=4200
      - PREFECT_UI_ENABLED=true
      - PREFECT_UI_STATIC_DIRECTORY=/ui_build
      - PREFECT_LOGGING_SERVER_LEVEL=DEBUG
      - PREFECT_API_DATABASE_DRIVER=postgresql+asyncpg
      - PREFECT_API_DATABASE_HOST=prefect-database
      - PREFECT_API_DATABASE_PORT=5432
      - PREFECT_API_DATABASE_NAME=prefect
      - PREFECT_API_DATABASE_USER=prefect
      - PREFECT_API_DATABASE_PASSWORD=prefect
does not work anymore - settings cannot be converted to environment variables (which used to be the sane default) ๐Ÿ˜• Anyone know how to fix this
Copy code
prefect-server                 | Traceback (most recent call last):
prefect-server                 |   File "/usr/local/bin/prefect", line 5, in <module>
prefect-server                 |     from prefect.cli import app
prefect-server                 |   File "/usr/local/lib/python3.12/site-packages/prefect/cli/__init__.py", line 12, in <module>
prefect-server                 |     import prefect.cli.shell
prefect-server                 |   File "/usr/local/lib/python3.12/site-packages/prefect/cli/shell.py", line 16, in <module>
prefect-server                 |     from prefect import flow
prefect-server                 |   File "<frozen importlib._bootstrap>", line 1412, in _handle_fromlist
prefect-server                 |   File "/usr/local/lib/python3.12/site-packages/prefect/__init__.py", line 113, in __getattr__
prefect-server                 |     module = importlib.import_module(mname, package=package)
prefect-server                 |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
prefect-server                 |   File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
prefect-server                 |     return _bootstrap._gcd_import(name[level:], package, level)
prefect-server                 |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
prefect-server                 |   File "/usr/local/lib/python3.12/site-packages/prefect/main.py", line 44, in <module>
prefect-server                 |     prefect.logging.configuration.setup_logging()
prefect-server                 |   File "/usr/local/lib/python3.12/site-packages/prefect/logging/configuration.py", line 71, in setup_logging
prefect-server                 |     config = load_logging_config(
prefect-server                 |              ^^^^^^^^^^^^^^^^^^^^
prefect-server                 |   File "/usr/local/lib/python3.12/site-packages/prefect/logging/configuration.py", line 41, in load_logging_config
prefect-server                 |     template.substitute(current_settings.to_environment_variables())
prefect-server                 |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
prefect-server                 |   File "/usr/local/lib/python3.12/site-packages/prefect/settings/base.py", line 92, in to_environment_variables
prefect-server                 |     env: Dict[str, Any] = self.model_dump(
prefect-server                 |                           ^^^^^^^^^^^^^^^^
prefect-server                 |   File "/usr/local/lib/python3.12/site-packages/pydantic/main.py", line 426, in model_dump
prefect-server                 |     return self.__pydantic_serializer__.to_python(
prefect-server                 |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
prefect-server                 | pydantic_core._pydantic_core.PydanticSerializationError: Error calling function `_serialize_secret_field`: AttributeError: 'str' object has no attribute 'get_secret_value'
f
This looks the same as what Iโ€™m also seeing: https://prefect-community.slack.com/archives/CL09KU1K7/p1736371234293269
b
Hi Fernando and Nas! Nas, I think you opened this issue in GitHub already, is that right? Alex is taking a look and proposed a workaround. Could you both give it a try?
f
@Bianca Hoch thanks for the update. Using
PREFECT_SERVER_DATABASE_CONNECTION_URL
works, although itโ€™s less than ideal for a situation where we want to get the credentials (user, password) from a secret store and to keep other options (host, port, db name) in configuration. This is not blocking me but it would be great to have it fixed over time. Thanks!
๐Ÿซก 1
๐Ÿ‘ 1
n
yes, @Bianca Hoch that's right, thanks for allocating some time to look into this, we appreciate it. and yes, the workaround does work, the original error has something to do with the fact that the password is a
SecretStr
(to avoid displaying it in logging contexts, in the ui etc) but a
str
is expected in certain situations - i've commented on the PR for Alex to take a look when and if he can. ๐Ÿ™‚