{"action":"created","issue":{"url":"https://api.github.com/repos/18F/open-data-maker/issues/164","labels_url":"https://api.github.com/repos/18F/open-data-maker/issues/164/labels{/name}","comments_url":"https://api.github.com/repos/18F/open-data-maker/issues/164/comments","events_url":"https://api.github.com/repos/18F/open-data-maker/issues/164/events","html_url":"https://github.com/18F/open-data-maker/pull/164","id":103617530,"number":164,"title":"API error handling, part 1","user":{"login":"yozlet","id":173848,"avatar_url":"https://avatars.githubusercontent.com/u/173848?v=3","gravatar_id":"","url":"https://api.github.com/users/yozlet","html_url":"https://github.com/yozlet","followers_url":"https://api.github.com/users/yozlet/followers","following_url":"https://api.github.com/users/yozlet/following{/other_user}","gists_url":"https://api.github.com/users/yozlet/gists{/gist_id}","starred_url":"https://api.github.com/users/yozlet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yozlet/subscriptions","organizations_url":"https://api.github.com/users/yozlet/orgs","repos_url":"https://api.github.com/users/yozlet/repos","events_url":"https://api.github.com/users/yozlet/events{/privacy}","received_events_url":"https://api.github.com/users/yozlet/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/18F/open-data-maker/labels/in%20progress","name":"in progress","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-27T23:45:30Z","updated_at":"2015-08-29T18:56:26Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/18F/open-data-maker/pulls/164","html_url":"https://github.com/18F/open-data-maker/pull/164","diff_url":"https://github.com/18F/open-data-maker/pull/164.diff","patch_url":"https://github.com/18F/open-data-maker/pull/164.patch"},"body":"Calling this \"part 1\" because there are still errors not yet handled (in which case, it'll just blow up with a 500 as usual) but @ultrasaurus agreed that Some Error Handling is better than none.\r\n\r\nThe ErrorChecker module scans the arguments sent to search and looks for badness. It compiles an array of error hashes, each of which includes an `error` code, a human readable `message`, the problematic `input`, and in certain cases some other entries with additional data. (See `spec/lib/data_magic/error_checker_spec.rb` for examples)\r\n\r\nIf the ErrorChecker finds errors, the API will return HTTP 400 along with a JSON object with the errors array under `errors`.\r\n\r\nErrors currently handled:\r\n * Parameter not found\r\n * Field not found (in a `fields` parameter)\r\n * Operator not found (if not `range`, `ne` or `not`)\r\n * Range format error\r\n\r\nNot yet handled:\r\n * Parameter type error\r\n * Range type error\r\n * Bad sort argument\r\n * Anything to do with geodata, zipcodes, distance etc.\r\n"},"comment":{"url":"https://api.github.com/repos/18F/open-data-maker/issues/comments/136025120","html_url":"https://github.com/18F/open-data-maker/pull/164#issuecomment-136025120","issue_url":"https://api.github.com/repos/18F/open-data-maker/issues/164","id":136025120,"user":{"login":"ultrasaurus","id":41906,"avatar_url":"https://avatars.githubusercontent.com/u/41906?v=3","gravatar_id":"","url":"https://api.github.com/users/ultrasaurus","html_url":"https://github.com/ultrasaurus","followers_url":"https://api.github.com/users/ultrasaurus/followers","following_url":"https://api.github.com/users/ultrasaurus/following{/other_user}","gists_url":"https://api.github.com/users/ultrasaurus/gists{/gist_id}","starred_url":"https://api.github.com/users/ultrasaurus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ultrasaurus/subscriptions","organizations_url":"https://api.github.com/users/ultrasaurus/orgs","repos_url":"https://api.github.com/users/ultrasaurus/repos","events_url":"https://api.github.com/users/ultrasaurus/events{/privacy}","received_events_url":"https://api.github.com/users/ultrasaurus/received_events","type":"User","site_admin":false},"created_at":"2015-08-29T18:56:26Z","updated_at":"2015-08-29T18:56:26Z","body":"This fails with nested fields, which is likely a bug in the field_types method.  Here's an example of a query that has errors and shouldn't (as a reminder to myself):  http://localhost:3000/v1/schools?2013.completion.rate_suppressed.overall__range=0.95..&fields=2013.completion.rate_suppressed.overall,school.name,2013.student.size&sort=2013.completion.rate_suppressed.overall:desc"}}