<@ULVA73B9P> - started seeing the following error ...
# ask-marvin
k
@Marvin - started seeing the following error in our prefect worker this weekend:
TypeError: issubclass() arg 1 must be a class
and
Copy code
Failed to initialize plugins: issubclass() arg 1 must be a class
from
File "/usr/local/lib/python3.10/site-packages/prefect/settings/legacy.py", line 102, in _get_valid_setting_names
m
thought for 361.4 seconds
Thanks for the details — that traceback points to Prefect’s settings introspection hitting an
issubclass()
on something that isn’t actually a class while Prefect is initializing (the log is surfaced as “Failed to initialize plugins…” because the init happens during import-time checks). This is almost always caused by a dependency bump (typically pydantic 2.x) interacting with the settings model on Python 3.9/3.10. If something in your image/env auto-updated over the weekend, that lines up. Can you share: - The output of
prefect version
from the worker - Your Python and pydantic versions - Whether you changed your base image or unpinned dependencies recently Quickest ways to get unblocked - Upgrade Prefect to the latest 3.x patch (we’ve hardened a bunch of settings and init paths recently):
Copy code
pip install --upgrade prefect
Latest release notes: Prefect releases (full changelog for the most recent patch: 3.6.21 → 3.6.22) - If you can’t upgrade Prefect immediately, pin pydantic to a stable version your environment is known to work with. For many users on Py 3.10, either sticking to the last known-good 2.10.x or jumping to a current 2.12.x has resolved this:
Copy code
pip install "pydantic==2.10.5"
  # or
  pip install "pydantic>=2.12,<2.13"
(Choose one; I’d start with upgrading to a recent 2.12.x if you’re not tightly pinned already.) Notes and context - The error you’re seeing bubbles up during Prefect’s import-time initialization. Even if you’re not using the experimental plugin system, Prefect still evaluates settings early, which is where this
issubclass()
check runs. - We’ve also seen settings validation errors show up under the same “Failed to initialize plugins” banner in logs; that label is just where the import-time error is captured. Example (different root cause, but same banner): Issue #19425 and another repro in a compose setup: Issue #20085. If you prefer a mitigation without changing packages right now, and if you’ve explicitly enabled the experimental plugin system, you can turn it off to reduce the amount of work done at import:
Copy code
# In the worker environment
export PREFECT_EXPERIMENTS_PLUGINS_ENABLED=0
However, if the underlying issue is pydantic’s type handling during settings model introspection, you’ll likely still want to upgrade Prefect or pin pydantic as above. If you can paste the full traceback plus your
prefect version
(it includes the pydantic version), I can recommend an exact pin or confirm whether a specific Prefect patch already includes a fix for your combo.