Slackbot
10/15/2025, 12:10 PMMarvin
10/15/2025, 12:10 PMMarvin
10/15/2025, 12:12 PMprefect version output)?
- What’s the exact error message/traceback?
- Are you running an “agent” (Prefect 2.x) or a “worker” (Prefect 3.x), and in what environment (local, Docker image, Kubernetes)?
- What versions of pydantic and pydantic-settings are installed?
Why I’m asking: Pydantic v2 is only compatible with Prefect 3.x. Prefect 2.x relied on Pydantic v1 APIs, so upgrading just Pydantic to v2 on a Prefect 2.x agent will break with import/validator errors.
Two common situations and fixes:
1) You’re on Prefect 2.x (agents)
- Symptom: ImportError/TypeError due to Pydantic v2 (e.g., cannot import name BaseSettings, validator errors).
- Fix: Pin Pydantic to v1 and avoid v2.
pip install "prefect<3" "pydantic<2"
- Longer-term: consider upgrading to Prefect 3.x workers to use Pydantic v2.
2) You’re on Prefect 3.x (workers) and just updated dependencies
- There is a known breaking change in pydantic-settings 2.9.0 that causes:
ImportError: cannot import name 'ConfigFileSourceMixin' from 'pydantic_settings.sources'
- Temporary fix: pin pydantic-settings to 2.8.1 (or any version < 2.9.0 until a Prefect fix is released).
pip install "pydantic>=2,<3" "pydantic-settings>=2,<2.9.0"
- Details: Issue: pydantic-settings 2.9.0 breaking change
- Background on 2.x vs 3.x and Pydantic v2 adoption: Support installation with Pydantic v2
If you paste the exact error and your prefect version plus the pip freeze lines for `pydantic`/`pydantic-settings`, I can confirm which path you’re on and give a targeted set of commands (and if you’re using a Docker/Helm image, I can suggest the right base image/pins).