-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
WSGIHeaderDict fails to get item if it's present and None in original dict #1452
Comments
if key has None value then .get(key) throws an Exception fixes bottlepy#1452
Header values in WSGI environment dicts should never be |
I'm also suspcting that WSGI headers can't have None values when they come to this code. |
Hm. Problem is, returning I think failing is the correct way to handle this, so you notice bugs in a WSGI server or middleware and have a chance to fix it. If you need a workaround, you could wrap bottle into a WSGI middleware that fixes those headers, or install a |
In general (and it was a reason why I found it) - this breaks previous behaviour. With version<0.13 those UT work well. If I try same code with old version then I get None value for 'z' key. In terms of http headers - user may pass just a key without a value and it means that value is empty string. So it's also reasonable soluction. |
new version has issue in get method bottlepy/bottle#1452 Change-Id: I84ae81757a09c4b204afa26e09ea7df1b0415aa4
Yes and no. Yes the behavior changed, but this is not a 'breaking change' because Bottle expects a WSGI compliant environment dictionary and if that expectation is not met, you enter 'undefined behavior' territory. Changing undefined behavior or fixing buggy behavior can happen anytime, even during patch releases. Relying on undefined behavior is actually a bug in itself and your tests revealed that bug. You can and should fix that on your side. If the bug only exists in your test framework, that's even better. No need to fix your actual application and push a new release, just fix the tests. This reminds me of https://xkcd.com/1172/. The old behavior was wrong, because returning |
new version has issue in get method bottlepy/bottle#1452 Change-Id: I84ae81757a09c4b204afa26e09ea7df1b0415aa4 (cherry picked from commit 23c6e6c)
get key with not None value
get absent key
get key with None value
The text was updated successfully, but these errors were encountered: