Skip to content

Commit

Permalink
Fixes #3379 - added check for no fields in point
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Horwitz committed Jul 21, 2015
1 parent 2aa2fe9 commit e19dea8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
### Features
- [#3376](https://github.com/influxdb/influxdb/pull/3376): Support for remote shard query mapping

### Bugfixes
- [#3405](https://github.com/influxdb/influxdb/pull/3405): Prevent database panic when fields are missing. Thanks @jhorwit2

## v0.9.2 [unreleased]

### Features
Expand Down
6 changes: 6 additions & 0 deletions tsdb/points.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,12 @@ func scanKey(buf []byte, i int) (int, []byte, error) {
return i, buf[start:i], fmt.Errorf("invalid tag format")
}

// This check makes sure we actually received fields from the user. #3379
// This will catch invalid syntax such as: `cpu,host=serverA,region=us-west`
if i >= len(buf) {
return i, buf[start:i], fmt.Errorf("missing fields")
}

// Now we know where the key region is within buf, and the locations of tags, we
// need to deterimine if duplicate tags exist and if the tags are sorted. This iterates
// 1/2 of the list comparing each end with each other, walking towards the center from
Expand Down
7 changes: 6 additions & 1 deletion tsdb/points_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,12 @@ func TestParsePointNoValue(t *testing.T) {
}

func TestParsePointNoFields(t *testing.T) {
_, err := ParsePointsString("cpu")
_, err := ParsePointsString("cpu_load_short,host=server01,region=us-west")
if err == nil {
t.Errorf(`ParsePoints("%s") mismatch. got nil, exp error`, "cpu_load_short,host=server01,region=us-west")
}

_, err = ParsePointsString("cpu")
if err == nil {
t.Errorf(`ParsePoints("%s") mismatch. got nil, exp error`, "cpu")
}
Expand Down

0 comments on commit e19dea8

Please sign in to comment.