Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

audio_path and friends are not paths #34

Open
dhdaines opened this issue Mar 8, 2024 · 1 comment
Open

audio_path and friends are not paths #34

dhdaines opened this issue Mar 8, 2024 · 1 comment

Comments

@dhdaines
Copy link
Collaborator

dhdaines commented Mar 8, 2024

If you try to use a path for audio_path, video_path, etc, then you get a very unfriendly validation error:

data.list[function-after[data_is_valid(), DataSource]].0.manifest.audio_path
  Input should be a valid URL, relative URL without a base [type=url_parsing, input_value='/assets/', input_type=str]
    For further information visit https://errors.pydantic.dev/2.4/v/url_parsing

Pydantic's validation definitely wants these to be URLs with a scheme, host, etc. I wonder about the wisdom of making these HttpUrl since in reality they are nearly always going to be relative (or absolute to the deployment root) paths. Plus it's in the name!

@dhdaines
Copy link
Collaborator Author

dhdaines commented Mar 8, 2024

It looks like you can get around this by making them Union[HttpUrl, str] but then you don't actually get any validation since Pydantic will always fall back to str (and they end up being strings in the JSON anyway).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant