Skip to content

Commit

Permalink
Merge pull request #1999 from influxdb/show-measurements-500
Browse files Browse the repository at this point in the history
Return status code 200 for measurement not found errors on show series.
  • Loading branch information
corylanou committed Mar 18, 2015
2 parents 4e77faf + b9a6085 commit 09fd15f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v0.9.0-rc14 [unreleased]

### Bugfixes
- [#1999](https://github.com/influxdb/influxdb/pull/1999): Return status code 200 for measurement not found errors on show series.

## v0.9.0-rc13 [2015-03-17]

### Features
Expand Down
3 changes: 2 additions & 1 deletion httpd/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ func isAuthorizationError(err error) bool {
}

func isMeasurementNotFoundError(err error) bool {
return (err.Error() == "measurement not found")
s := err.Error()
return strings.HasPrefix(s, "measurement") && strings.HasSuffix(s, "not found")
}

func isFieldNotFoundError(err error) bool {
Expand Down
19 changes: 19 additions & 0 deletions httpd/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,25 @@ func TestBatchWrite_UnmarshalRFC(t *testing.T) {
}
}

// Ensure that even if a measurement is not found, that the status code is still 200
func TestHandler_ShowMeasurementsNotFound(t *testing.T) {
c := test.NewMessagingClient()
defer c.Close()
srvr := OpenAuthlessServer(c)
srvr.CreateDatabase("foo")
srvr.CreateRetentionPolicy("foo", influxdb.NewRetentionPolicy("bar"))
srvr.SetDefaultRetentionPolicy("foo", "bar")
s := NewHTTPServer(srvr)
defer s.Close()

status, body := MustHTTP("GET", s.URL+`/query`, map[string]string{"q": "SHOW SERIES from bin", "db": "foo"}, nil, "")
if status != http.StatusOK {
t.Fatalf("unexpected status: %d", status)
} else if body != `{"results":[{"error":"measurement \"bin\" not found"}]}` {
t.Fatalf("unexpected body: %s", body)
}
}

func TestHandler_Databases(t *testing.T) {
c := test.NewMessagingClient()
defer c.Close()
Expand Down

0 comments on commit 09fd15f

Please sign in to comment.