Skip to content

Pydantic settings cannot parse PREFECT_CLIENT_CUSTOM_HEADERS #18611

@rekumar

Description

@rekumar

Bug summary

I'm trying to set a custom header for the prefect client using PREFECT_CLIENT_CUSTOM_HEADERS as per docs. This triggers a Pydantic validation error in the Settings class, as the json string is not being parsed to a dictionary for some reason.

Problem is current on my fork of branch 8c02ab1.

uv run prefect config set PREFECT_CLIENT_CUSTOM_HEADERS='{"CF-Access-Client-Id": "your-client-id", "CF-Access-Client-Secret": "your-secret"}' #exact line from the docs
Validation error(s) for setting PREFECT_CLIENT_CUSTOM_HEADERS

 - Input should be a valid dictionary

Also fails if I manually put this string into profiles.toml

Simple fix is to put a field_validator on ClientSettings.custom_headers to json.loads if receiving a string.

Version info

Version:             3.4.11.dev4+3.gb6f64e41da
API version:         0.8.4
Python version:      3.11.11
Git commit:          b6f64e41
Built:               Tue, Jul 29, 2025 10:02 PM
OS/Arch:             darwin/arm64
Profile:             local
Server type:         server
Pydantic version:    2.11.7

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions