Skip to content
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

Improve error when ES Ingest node plugins are not loaded #3676

Merged
merged 3 commits into from Mar 1, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Prev

addressed comments and added more tests

  • Loading branch information...
tsg committed Feb 28, 2017
commit 779624608e4373cddac8dfb9c510a7095deb0e7f
@@ -302,13 +302,13 @@ func interpretError(initialErr error, body []byte) error {
var response1x struct {
Error string `json:"error"`
}
json.Unmarshal(body, &response1x)
if response1x.Error != "" {
err1x := json.Unmarshal(body, &response1x)
if err1x == nil && response1x.Error != "" {
return fmt.Errorf("The Filebeat modules require Elasticsearch >= 5.0. "+
"This is the response I got from Elasticsearch: %s", body)
}

return fmt.Errorf("couldn't load pipeline: %v. Additionally, error decoding response body: %s.",
return fmt.Errorf("couldn't load pipeline: %v. Additionally, error decoding response body: %s",
initialErr, body)
}

@@ -379,6 +379,17 @@ func TestInterpretError(t *testing.T) {
Input: `{"error":"InvalidIndexNameException[[_ingest] Invalid index name [_ingest], must not start with '_']","status":400}`,
Output: `The Filebeat modules require Elasticsearch >= 5.0. This is the response I got from Elasticsearch: {"error":"InvalidIndexNameException[[_ingest] Invalid index name [_ingest], must not start with '_']","status":400}`,
},
{
Test: "bad json",
Input: `blah`,
Output: `couldn't load pipeline: test. Additionally, error decoding response body: blah`,
},
{
Test: "another error",
Input: `{"error":{"root_cause":[{"type":"test","reason":""}],"type":"test","reason":""},"status":400}`,
Output: "couldn't load pipeline: test. Response body: " +
`{"error":{"root_cause":[{"type":"test","reason":""}],"type":"test","reason":""},"status":400}`,
},
}

for _, test := range tests {
@@ -725,7 +725,7 @@ func (conn *Connection) execHTTPRequest(req *http.Request) (int, []byte, error)

obj, err := ioutil.ReadAll(resp.Body)
if err != nil {
return status, nil, err
return status, nil, retErr
}
return status, obj, retErr
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.