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

fields.URL validation error should specify "not a valid FQDN" if trying to pass hostname without domain #2243

Open
ff137 opened this issue Feb 20, 2024 · 0 comments

Comments

@ff137
Copy link

ff137 commented Feb 20, 2024

The current validation error message: 'Not a valid URL.' is not descriptive enough to help the user, especially when they are passing a value that would appear to be a valid URL to most people, such as a docker hostname: http://test-url:8001

Sample code:

from marshmallow import Schema, fields

class TestSchema(Schema):
  url = fields.URL(required=True)

TestSchema().load({"url": "http://192.168"}) // this works
TestSchema().load({"url": "http://test-url"}) // this doesn't work
TestSchema().load({"url": "derp"}) // and this has the same error message as http://test-url

This is because fields.URL has a default: require_tld=True, for require_tld: Whether to reject non-FQDN hostnames.
FQDN = fully-qualified domain name. i.e. http://server1.example.com is a FQDN, http://server1 is not.

Suggestion: error message should be more descriptive when require_tld is True, and validation fails FQDN requirement.

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