Closed Bug 1311977 Opened 8 years ago Closed 8 years ago

ResultSetViewSet.list "KeyError: ..." with invalid fromchange values

Categories

(Tree Management :: Treeherder: API, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: emorley, Assigned: wlach)

References

(Blocks 1 open bug)

Details

We should handle this case gracefully (with an HTTP 400) not HTTP 500. /treeherder.webapp.api.resultset:ResultSetViewSet.list File "/app/.heroku/python/lib/python2.7/site-packages/rest_framework/views.py", line 463, in dispatch File "/app/treeherder/webapp/api/utils.py", line 104, in use_jobs_model File "/app/treeherder/webapp/api/resultset.py", line 60, in list exceptions:KeyError: u'8948474958936717641.owasp.org' parameters fromchange 8948474958936717641.owasp.org https://rpm.newrelic.com/accounts/677903/applications/14179733/traced_errors/70d13c62-9482-11e6-9c7c-b82a72d22a14_4260_8309
It seems that for this and the related bugs, we really need some kind of jsonschema-like validation for API inputs. I've had a quick glance but it's not clear if Django rest framework has such a thing. Having to roll our own handling for this on every API endpoint seems a bit tedious. Any ideas?
Flags: needinfo?(wlachance)
Flags: needinfo?(cdawson)
(In reply to Ed Morley [:emorley] from comment #1) > It seems that for this and the related bugs, we really need some kind of > jsonschema-like validation for API inputs. I've had a quick glance but it's > not clear if Django rest framework has such a thing. Having to roll our own > handling for this on every API endpoint seems a bit tedious. Any ideas? I'm not aware of anything. In general I think we should avoid writing custom endpoints like this, there should be no reason to now that we're not using datasource for new models. I'm currently rewriting this endpoint as part of bug 1311185, I'll try to take care of this case then.
Assignee: nobody → wlachance
Depends on: 1311185
Flags: needinfo?(wlachance)
I agree we shouldn't be writing custom endpoints in a post-datasource world, however some of the other 500s have come from our ORM endpoints too.
I think that Serializers are the suggested way (deserializing the incoming data) in DRF. Though I've never done it, so I'm not certain all that's involved. I believe we only have 2 creation endpoints to cover: Jobs and Resultsets. So perhaps that's not too much work.
Flags: needinfo?(cdawson)
This issue is for GETs too, so all endpoints.
The code that was triggering this is no longer active.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.