-
-
Notifications
You must be signed in to change notification settings - Fork 581
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
Email format not properly validated #403
Comments
{'format': 'email'}
not properly validated
The email validator is intentionally unimplemented, because validating email addresses isn't really a reasonable concept. It's the one and only way that That being said, your attitude and commentary isn't welcome. Use the library if it helps you, don't if it doesn't, I don't really care about your "trust" in the library. |
I'm sorry, I thought I did a thorough job of checking previous issues and the docs, but I missed those caveats. My intention here wasn't to complain, I've enjoyed and stuck with this library for about 4 years now, so thanks for your work on it. I am concerned, though, that I spent all that time not validating email addresses, and I imagine your other thousands of users might be in the same place, particularly given the number of issues similar to this one. This did cause a (small) problem in production for us, so if you want to prevent downstream users from footgunning themselves, maybe do a Could you link to the discussion about potentially removing the validator, just out of curiosity? |
After looking through the validation section of the docs again and not seeing anything calling out email validation in particular, I went ahead and created #404. It still seems worth it to me to remove or warn about the email validator, as well as validators that require dependencies or formats that aren't implemented, even though the library is following jsonschema's specification to let that stuff pass. You'd at least get fewer people creating duplicate issues like this one. |
@staab how do you feel here after that clarification (thanks again!) The issue with a warning (beyond the fact that the stdlib crippled its own warning system, which is somewhat fixable) is that it's not really possible to distinguish between someone who's accidentally forgot to install a dependency from someone who actually doesn't mean to use format for validation. If you still think there's more here though happy to discuss. |
I'm beginning to understand the stickiness of the issue, for sure. I do still feel pretty unsatisfied though, for the following reasons:
As far as warnings, I might suggest requiring the user to configure jsonschema (globally, or even better, as an argument to Hope that helps, and I'd be happy to help implement some of this stuff if you decide on a way forward. |
We are working on improving this situation, and others regarding extensibility and modularity (specifically being able to know whether an implementation handles your extensions and failing appropriately if not) See json-schema-org/json-schema-spec#561 (basics) and json-schema-org/json-schema-spec#563 (formats). This approach would retain the default permissive behavior, while providing both schema authors and schema implementors control over what they require / accept. I would advise against sinking too much time into implementation-specific band-aids on this as we do plan to address it in the next draft. Better to spend that effort adding support for draft-08 as soon as it's out. |
Neat! That sounds like the ideal solution to me. |
(I'm speaking only about existing drafts, though thankfully @handrews is helpfully chiming in)
I think in this comment (and others) you're taking an extreme view on what This just isn't the case -- the The fact that you've taken such an extreme definition means that you have different expectations, so I think you're applying some principles here that just don't apply to Do some users expect If you do press me on whether I think that's a good idea, no probably not, I'd prefer to probably split format into a few that are well defined and likely widely supported, and "the rest", and then to mandate behavior one way or the other.
I think the end of this paragraph is agreeing with the following, but just to be clear again: my issue with the email validator is that I literally call what is implemented in
Definitely agree with this one :/
So I'm somewhat open to this one, if by this what you mean is "no more default behavior for I'll admit though that I'm quite behind on reading up on the things @handrews mentioned, so maybe my opinions will change once I'm caught up. |
I haven't read the spec (I read half of draft 3 a number of years ago), so my suggestions here are entirely based on my own instincts. If the philosophy of jsonschema conflicts, with my own, for sure go with jsonschema's. It sounds like you've heard me loud and clear, so I'm pretty satisfied here. I think the |
@staab part of the recent spec work has involved classifying keywords into assertions (which produce a boolean output) annotations (which attach some data in some way that an application can use), and applicators (which apply subschema(s) and combine or modify their results in some way (e.g.
The hybrid behavior is a little weird, and I'm hoping that by clarifying that framework it's a little more obvious when the spec is read that the keywords behave a bit differently. |
The above code doesn't raise an error, but should, at least as far as I understand RFC 5322.
Upon further investigation, your email checking function is terrible. I've been trusting this library to handle the hard parts of validation for me (particularly emails!), but even a regex would have been a better way to validate emails. Just for instance, this passes validation:
I'd really like to see the email validator pass this suite of tests.
It's fair that you haven't implemented the validation, since the jsonschema spec doesn't require format validation, but partway implementing it, and not warning users (either through raising errors on schemas relying on incompletely-implemented formats, or through documentation), that your format checker doesn't actually validate against the RFC, is pretty bad. My trust in this library has been shaken, and I'll be auditing my code to add custom validation logic where necessary, or switching away entirely.
The text was updated successfully, but these errors were encountered: