-
Notifications
You must be signed in to change notification settings - Fork 145
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
Unbound deferred validators are ignored? #47
Comments
The intent had something to do with the code in this class: http://svn.repoze.org/repoze.itory/trunk/repoze/itory/content.py ... but that code no longer is operative, it was just an experiment... I don't even really remember the true use case. I'd be fine defaulting Field to raising an error if a deferred value is found, with a flag to the Field constructor to ignore. |
I just spent a few minutes looking through the repoze.itory (awesome name) code, and I'm not much the wiser for it. (I'll take your word for it — I couldn't find a reason to ignore deferred validators in there.) I will work up a pull request. Here's the plan:
|
Validators aren't the only things that can be deferred (the missing value, the default value, and actually any other attribute of a SchemaNode can be deferred). Now that I've looked at it a bit, I'd probably just ditch the existing behavior and always raise an exception when a deferred is unexpectly encountered. UnboundSchemaError or something. My crazy code can lose. |
Good timing. I just finished hacking up the first plan. The current behavior w.r.t. deferred I've just grepped the source (deform's too), and those appear to be the only places (besides Anyhow, here's what I came up with: dairiki/colander@b958cc565afb I'm happy to rework it, if you think it needs it. |
Another option occurred to me while sleeping (fitfully) last night. We could add a Optionally, if we want to provide a method to specify "default" values for unbound deferreds, |
Any news on this? |
Perhaps |
I think it just needs to be required. I'm sorry I've not been able to do much with it. Can't promise any ETA, sorry. |
I agree that an exception should be raised when deserializing with an unbound validator. I've run into this and found it confusing that my unbound validator was being ignored. What exception should be raised? I guess we could add UnboundDeferredError as @dairiki suggests. |
via #172 |
On IRC this morning, subsu pointed out to me that unbound deferred validators are silently ignored when deserializing. Indeed, this behavior is documented.
This seems completely backwards to me. The validators are supposed to make particular assertions about the integrity of the unserialized data. If I forget to bind one, it is a programming error, and I want an exception thrown. I certainly don't want untrusted input to be passed through unvalidated. This is freaking me out, man!
Is this really what was intended? (Why?) Anyhow, I propose either: changing this behavior (which might be problematic, given that it is documented and all); or adding a second deferred (sub)class (
compulsory_deferred
or some such) for which errors will be thrown if an attempt is made to use them before they are bound.The text was updated successfully, but these errors were encountered: