Skip to content
This repository was archived by the owner on Jan 31, 2018. It is now read-only.

[bug 933786] Fix strip error#213

Merged
willkg merged 1 commit intomozilla:masterfrom
willkg:933786-fix-device-strip
Feb 11, 2014
Merged

[bug 933786] Fix strip error#213
willkg merged 1 commit intomozilla:masterfrom
willkg:933786-fix-device-strip

Conversation

@willkg
Copy link
Copy Markdown
Member

@willkg willkg commented Feb 11, 2014

We get this weird error on input-stage (and only on stage) where someone
is using the Input API and sending in nonsensical POST data and it
somehow manages to result in attrs['device'] being None which causes an
error.

I spent some time looking into it and I can't figure out how it ends up
as a None. I don't know what the actual input that's causing the error
is.

Regardless, this alleviates that by making sure it's a unicode but it's
goofipants.

r?

@willkg
Copy link
Copy Markdown
Member Author

willkg commented Feb 11, 2014

I'm totally game for other ideas here.

@rlr
Copy link
Copy Markdown
Contributor

rlr commented Feb 11, 2014

This branch fixes the issue for me

$ curl -X POST -H "Content-Type: application/json" -d '{"happy":true,"description":"awesome", "product": "Firefox OS", "device":null}' http://localhost:8000/api/v1/feedback/
{"happy": true, "url": "", "description": "awesome", "product": "Firefox OS", "channel": "", "version": "", "locale": "", "platform": "", "country": "", "manufacturer": "", "device": "", "email": ""}

r+

DRF allows nulls as valid values for CharField. This creates
NoNullsCharField which restores sanity to the world.

This fixes the strip error by raising a ValidationError which will send
an error to the client rather than letting the value through and having
it throw an AttributeError where it shouldn't be.
@willkg
Copy link
Copy Markdown
Member Author

willkg commented Feb 11, 2014

^^^ That redoes the fix with a much better fix that prevents nulls for all the fields.

r?

@rlr
Copy link
Copy Markdown
Contributor

rlr commented Feb 11, 2014

$ curl -X POST -H "Content-Type: application/json" -d '{"happy":true,"description":"awesome", "product": "Firefox OS", "device":null}' http://localhost:8000/api/v1/feedback/
{"device": ["Value cannot be null"]}

r+!

@willkg willkg merged commit 2324aa3 into mozilla:master Feb 11, 2014
@willkg
Copy link
Copy Markdown
Member Author

willkg commented Feb 11, 2014

2324aa3 [bug 933786] Fix strip error

@willkg willkg deleted the 933786-fix-device-strip branch February 12, 2014 01:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants