-
-
Notifications
You must be signed in to change notification settings - Fork 16.2k
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
BadRequestKeyError no longer contains the missing key from self.form as of 1.0.3 #3249
Comments
I can't reproduce the issue when in debug mode, Then again, this "only show the key in debug mode" is a completely made up thing I decided when adding the key to the output, it wasn't ever shown before Flask 1.0. I can just have it show all the time and never remove it? |
I don't understand why behavior in a custom errorhandler should ever depend on debug mode...? I agree it's reasonable to hide the keys in the default error response in non-debug mode, but if I'm doing my own error handling (and, say, logging details about the missing key), I should have access to the full args.
Also, this behavior is with werkzeug 0.15 both on flask 1.0.2 and 1.0.3...
Is there any way to monkey patch around this without enabling debug mode in production? For now I have to pin 1.0.2 in several dozen projects...
--
James Brown,
currently mobile
… On Jun 3, 2019, at 10:15, David Lord ***@***.***> wrote:
I can't reproduce the issue when in debug mode, e.args[0] is the key. Out of debug mode, this now fails because we clear the args, since in Werkzeug 0.15 that's what triggers hiding the key, and I didn't think it was good to show the keys and non-standard error messages outside debug mode.
Then again, this "only show the key in debug mode" is a completely made up thing I decided when adding the key to the output, it wasn't ever shown before Flask 1.0. I can just have it show all the time and never remove it?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
It doesn't exactly depend on debug mode, losing the key outside debug mode is an unintended side-effect of the new implementation of the key showing/hiding in Werkzeug 0.15, which gained support in Flask 1.0. You should set |
I can confirm that setting I still am kind of negative on the idea of emptying out |
If you have a suggestion for a better way to only output the information in Flask's debug mode, when the feature itself is part of Werkzeug, I'm open to review a PR to Werkzeug! |
Is |
Expected Behavior
When
self.form
is indexed with a key that isn't present,BadRequestKeyError
is raised. Under 1.0.2 and below, the.args
property of this exception contained the actual missing key -- great for lightweight error presentation.Minimal demonstration:
Under 1.0.2 and below we see the following behavior:
Under 1.0.3:
This occurs independent of
$FLASK_DEBUG
Actual Behavior
There appears to be no way to get at the missing key from an error handler.
Environment
The text was updated successfully, but these errors were encountered: