8000 AnyUrl doesn't accept file URLs with implicit host · Issue #1983 · pydantic/pydantic · GitHub
[go: up one dir, main page]

Skip to content

AnyUrl doesn't accept file URLs with implicit host #1983

@torfsen

Description

@torfsen

Bug

Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":

             pydantic version: 1.5.1
            pydantic compiled: True
                 install path: /shared/conda/envs/ubide-mastr/lib/python3.6/site-packages/pydantic
               python version: 3.6.10 |Anaconda, Inc.| (default, May  8 2020, 02:54:21)  [GCC 7.3.0]
                     platform: Linux-5.4.0-48-generic-x86_64-with-debian-buster-sid
     optional deps. installed: []
import pydantic

class MyModel(pydantic.BaseModel):
    url: pydantic.AnyUrl

MyModel(url='file:///foo/bar')

raises:

ValidationError: 1 validation error for MyModel
url
  URL host invalid (type=value_error.url.host)

However, MyModel(url='file://hostname/foo/bar'), i.e. a URL with an explicit hostname, works.

RFC 8089 says that the hostname is optional. Hence I would expect that AnyUrl would accept that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug V1Bug related to Pydantic V1.X

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0