{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/10643","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/10643/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/10643/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/10643/events","html_url":"https://github.com/elastic/elasticsearch/pull/10643","id":69108393,"number":10643,"title":"Render REST errors in a structural way","user":{"login":"s1monw","id":973334,"avatar_url":"https://avatars.githubusercontent.com/u/973334?v=3","gravatar_id":"","url":"https://api.github.com/users/s1monw","html_url":"https://github.com/s1monw","followers_url":"https://api.github.com/users/s1monw/followers","following_url":"https://api.github.com/users/s1monw/following{/other_user}","gists_url":"https://api.github.com/users/s1monw/gists{/gist_id}","starred_url":"https://api.github.com/users/s1monw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s1monw/subscriptions","organizations_url":"https://api.github.com/users/s1monw/orgs","repos_url":"https://api.github.com/users/s1monw/repos","events_url":"https://api.github.com/users/s1monw/events{/privacy}","received_events_url":"https://api.github.com/users/s1monw/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/discuss","name":"discuss","color":"fbca04"},{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/v2.0.0","name":"v2.0.0","color":"dddddd"},{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/WIP","name":"WIP","color":"fef2c0"}],"state":"open","locked":false,"assignee":{"login":"rashidkpc","id":1250387,"avatar_url":"https://avatars.githubusercontent.com/u/1250387?v=3","gravatar_id":"","url":"https://api.github.com/users/rashidkpc","html_url":"https://github.com/rashidkpc","followers_url":"https://api.github.com/users/rashidkpc/followers","following_url":"https://api.github.com/users/rashidkpc/following{/other_user}","gists_url":"https://api.github.com/users/rashidkpc/gists{/gist_id}","starred_url":"https://api.github.com/users/rashidkpc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rashidkpc/subscriptions","organizations_url":"https://api.github.com/users/rashidkpc/orgs","repos_url":"https://api.github.com/users/rashidkpc/repos","events_url":"https://api.github.com/users/rashidkpc/events{/privacy}","received_events_url":"https://api.github.com/users/rashidkpc/received_events","type":"User","site_admin":false},"milestone":null,"comments":5,"created_at":"2015-04-17T10:04:20Z","updated_at":"2015-04-23T08:46:34Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/10643","html_url":"https://github.com/elastic/elasticsearch/pull/10643","diff_url":"https://github.com/elastic/elasticsearch/pull/10643.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/10643.patch"},"body":"This is a first cut aiming at progress rather than perfection for #3303\r\n\r\nIt renders errors on the REST layer as JSON to allow more insight into the error message ie\r\nthe query with a missing index renders like this:\r\n\r\n```\r\nGET localhost:9200/foo1/_search/?q=~3&pretty=true\r\n{\r\n  \"error\" : {\r\n    \"type\" : \"index_missing_exception\",\r\n    \"reason\" : \"[foo1] missing\"\r\n  },\r\n  \"status\" : 404\r\n}\r\n```\r\n\r\nor a search phase exception:\r\n\r\n```\r\nGET localhost:9200/_search?q=~3&pretty=true\r\n{\r\n  \"error\" : {\r\n    \"type\" : \"search_phase_execution_exception\",\r\n    \"reason\" : \"all shards failed\",\r\n    \"phase\" : \"query\",\r\n    \"failed_shards\" : [ {\r\n      \"shard\" : 0,\r\n      \"index\" : \"foo\",\r\n      \"node\" : \"0-75uocCQhyX4clLGbE6OQ\",\r\n      \"reason\" : {\r\n        \"type\" : \"search_parse_exception\",\r\n        \"reason\" : \"Failed to parse source [{\\\"query\\\":{\\\"query_string\\\":{\\\"query\\\":\\\"~3\\\",\\\"lowercase_expanded_terms\\\":true,\\\"analyze_wildcard\\\":false}}}]\",\r\n        \"caused_by\" : {\r\n          \"type\" : \"query_parsing_exception\",\r\n          \"reason\" : \"[foo] Failed to parse query [~3]\",\r\n          \"caused_by\" : {\r\n            \"type\" : \"parse_exception\",\r\n            \"reason\" : \"Cannot parse '~3': Encountered \\\" <FUZZY_SLOP> \\\"~3 \\\"\\\" at line 1, column 0.\\nWas expecting one of:\\n    <NOT> ...\\n    \\\"+\\\" ...\\n    \\\"-\\\" ...\\n    <BAREOPER> ...\\n    \\\"(\\\" ...\\n    \\\"*\\\" ...\\n    <QUOTED> ...\\n    <TERM> ...\\n    <PREFIXTERM> ...\\n    <WILDTERM> ...\\n    <REGEXPTERM> ...\\n    \\\"[\\\" ...\\n    \\\"{\\\" ...\\n    <NUMBER> ...\\n    <TERM> ...\\n    \\\"*\\\" ...\\n    \",\r\n            \"caused_by\" : {\r\n              \"type\" : \"parse_exception\",\r\n              \"reason\" : \"Encountered \\\" <FUZZY_SLOP> \\\"~3 \\\"\\\" at line 1, column 0.\\nWas expecting one of:\\n    <NOT> ...\\n    \\\"+\\\" ...\\n    \\\"-\\\" ...\\n    <BAREOPER> ...\\n    \\\"(\\\" ...\\n    \\\"*\\\" ...\\n    <QUOTED> ...\\n    <TERM> ...\\n    <PREFIXTERM> ...\\n    <WILDTERM> ...\\n    <REGEXPTERM> ...\\n    \\\"[\\\" ...\\n    \\\"{\\\" ...\\n    <NUMBER> ...\\n    <TERM> ...\\n    \\\"*\\\" ...\\n    \"\r\n            }\r\n          }\r\n        }\r\n      }\r\n    }]\r\n  },\r\n  \"status\" : 400\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/95493224","html_url":"https://github.com/elastic/elasticsearch/pull/10643#issuecomment-95493224","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/10643","id":95493224,"user":{"login":"s1monw","id":973334,"avatar_url":"https://avatars.githubusercontent.com/u/973334?v=3","gravatar_id":"","url":"https://api.github.com/users/s1monw","html_url":"https://github.com/s1monw","followers_url":"https://api.github.com/users/s1monw/followers","following_url":"https://api.github.com/users/s1monw/following{/other_user}","gists_url":"https://api.github.com/users/s1monw/gists{/gist_id}","starred_url":"https://api.github.com/users/s1monw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s1monw/subscriptions","organizations_url":"https://api.github.com/users/s1monw/orgs","repos_url":"https://api.github.com/users/s1monw/repos","events_url":"https://api.github.com/users/s1monw/events{/privacy}","received_events_url":"https://api.github.com/users/s1monw/received_events","type":"User","site_admin":false},"created_at":"2015-04-23T08:46:34Z","updated_at":"2015-04-23T08:46:34Z","body":"@kimchy @clintongormley @rashidkpc I think we are ready here any more comments on the API? Changes I made are this:\r\n\r\n * `group_shard_failures` defaults to `true` \r\n * `human_error` is cut over to `root_cause` including a type (see below)\r\n * `elasticsearch_` prefix is removed...\r\n```JSON\r\nGET /_search/asf?q=::&pretty=true\r\n{\r\n  \"error\" : {\r\n    \"root_cause\" : [ {\r\n      \"type\" : \"illegal_argument_exception\",\r\n      \"reason\" : \"No feature for name [asf]\"\r\n    } ],\r\n    \"type\" : \"illegal_argument_exception\",\r\n    \"reason\" : \"No feature for name [asf]\"\r\n  },\r\n  \"status\" : 400\r\n}\r\n```\r\n\r\n * Grouped failures are reflected in the response (see `\"grouped\" : true`) use `group_shard_failures=false` in the request to get all the response\r\n```JSON\r\nGET /_search?q=::&pretty=true\r\n{\r\n  \"error\" : {\r\n    \"root_cause\" : [ {\r\n      \"type\" : \"search_phase_execution_exception\",\r\n      \"reason\" : \"all shards failed\"\r\n    } ],\r\n    \"type\" : \"search_phase_execution_exception\",\r\n    \"reason\" : \"all shards failed\",\r\n    \"phase\" : \"query\",\r\n    \"grouped\" : true,\r\n    \"failed_shards\" : [ {\r\n      \"shard\" : 0,\r\n      \"index\" : \"foo\",\r\n      \"node\" : \"SvSibBJsTGKcgfyIDchoyA\",\r\n      \"reason\" : {\r\n        \"type\" : \"search_parse_exception\",\r\n        \"reason\" : \"Failed to parse source [{\\\"query\\\":{\\\"query_string\\\":{\\\"query\\\":\\\"::\\\",\\\"lowercase_expanded_terms\\\":true,\\\"analyze_wildcard\\\":false}}}]\",\r\n        \"caused_by\" : {\r\n          \"type\" : \"query_parsing_exception\",\r\n          \"reason\" : \"Failed to parse query [::]\",\r\n          \"index\" : \"foo\",\r\n          \"caused_by\" : {\r\n            \"type\" : \"parse_exception\",\r\n            \"reason\" : \"Cannot parse '::': Encountered \\\" \\\":\\\" \\\": \\\"\\\" at line 1, column 0.\\n..  \",\r\n            \"caused_by\" : {\r\n              \"type\" : \"parse_exception\",\r\n              \"reason\" : \"Encountered \\\" \\\":\\\" \\\": \\\"\\\" at line 1, column 0.\\n...\"\r\n            }\r\n          }\r\n        }\r\n      }\r\n    } ]\r\n  },\r\n  \"status\" : 400\r\n}\r\n```\r\n\r\nI think we are ready here... we can now improve stuff as we go..."}}