parent
73a5747fa6
commit
0994c8d9d5
|
@ -9,6 +9,7 @@
|
|||
- [#2415](https://github.com/influxdb/influxdb/pull/2415): Raft leader ID now set on election after failover. Thanks @xiaost
|
||||
- [#2426](https://github.com/influxdb/influxdb/pull/2426): Fix race condition around listener address in openTSDB server.
|
||||
- [#2426](https://github.com/influxdb/influxdb/pull/2426): Fix race condition around listener address in Graphite server.
|
||||
- [#2429](https://github.com/influxdb/influxdb/pull/2429): Ensure no field value is null.
|
||||
|
||||
### Features
|
||||
- [#2410](https://github.com/influxdb/influxdb/pull/2410) Allow configuration of Raft timers
|
||||
|
|
|
@ -1184,6 +1184,26 @@ func TestHandler_serveWriteSeriesWithNoFields(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestHandler_serveWriteSeriesWithNullFields(t *testing.T) {
|
||||
c := test.NewDefaultMessagingClient()
|
||||
defer c.Close()
|
||||
srvr := OpenAuthenticatedServer(c)
|
||||
srvr.CreateDatabase("foo")
|
||||
srvr.CreateRetentionPolicy("foo", influxdb.NewRetentionPolicy("bar"))
|
||||
s := NewAPIServer(srvr)
|
||||
defer s.Close()
|
||||
|
||||
status, body := MustHTTP("POST", s.URL+`/write`, nil, nil, `{"database" : "foo", "retentionPolicy" : "bar", "points": [{"name": "cpu", "fields": {"country": null}}]}`)
|
||||
|
||||
expected := fmt.Sprintf(`{"error":"%s"}`, influxdb.ErrFieldIsNull.Error())
|
||||
|
||||
if status != http.StatusInternalServerError {
|
||||
t.Fatalf("unexpected status: %d", status)
|
||||
} else if body != expected {
|
||||
t.Fatalf("result mismatch:\n\texp=%s\n\tgot=%s\n", expected, body)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandler_serveWriteSeriesWithAuthNilUser(t *testing.T) {
|
||||
c := test.NewDefaultMessagingClient()
|
||||
defer c.Close()
|
||||
|
|
|
@ -117,6 +117,9 @@ var (
|
|||
// ErrFieldsRequired is returned when a point does not any fields.
|
||||
ErrFieldsRequired = errors.New("fields required")
|
||||
|
||||
// FieldIsNull is returned when one of a point's field is null.
|
||||
ErrFieldIsNull = errors.New("field value is null")
|
||||
|
||||
// ErrFieldOverflow is returned when too many fields are created on a measurement.
|
||||
ErrFieldOverflow = errors.New("field overflow")
|
||||
|
||||
|
|
|
@ -1766,11 +1766,17 @@ func (s *Server) WriteSeries(database, retentionPolicy string, points []Point) (
|
|||
database, retentionPolicy, len(points))
|
||||
}
|
||||
|
||||
// Make sure every point has at least one field.
|
||||
// Make sure every point is valid.
|
||||
for _, p := range points {
|
||||
if len(p.Fields) == 0 {
|
||||
return 0, ErrFieldsRequired
|
||||
}
|
||||
|
||||
for _, f := range p.Fields {
|
||||
if f == nil {
|
||||
return 0, ErrFieldIsNull
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the retention policy is not set, use the default for this database.
|
||||
|
|
Loading…
Reference in New Issue