Skip to content

master: Alpha stops running when querying for invalid datetime value. #3166

@danielmai

Description

@danielmai

What version of Dgraph are you using?

master.

$ dgraph version

Dgraph version   : v1.0.12-rc3-225-g207e1349b
Commit SHA-1     : 207e1349b
Commit timestamp : 2019-03-15 16:22:58 -0700
Branch           : master
Go version       : go1.11.5

Have you tried reproducing the issue with latest release?

This does not happen in v1.0.

Steps to reproduce the issue (command/config used to run Dgraph).

  • Start a Dgraph cluster
  • Run schema update to set predicate datetime type:
curl localhost:8080/alter -d 'pred.date: datetime .'
  • Commit a mutation with an invalid datetime value (empty string). This mutation is successful.
curl -H "X-Dgraph-CommitNow: true" localhost:8080/mutate -d '{
  set {
    _:n <pred.date> "" .
  }
}'
  • Run a query for that predicate.
curl localhost:8080/query -d '{
  q(func: has(pred.date)) {
    uid
    pred.date
  }
}'

Alpha shows this error log and stops running:

2019/03/18 18:07:30 Error while interpreting appropriate type from binary error: Time.UnmarshalBinary: no data

The query never succeeds since the Alpha stopped after receiving the query.

Expected behaviour and actual result.

Dgraph shouldn't accept invalid data. In v1.0.13 (latest), the mutation does not succeed since "" is an invalid datetime format.

curl -H "X-Dgraph-CommitNow: true" http://localhost:8180/mutate -d '
{
  set {
    _:n <pred.date> "" .
  }
}'
# {
#   "errors": [
#     {
#       "code": "ErrorInvalidRequest",
#       "message": "parsing time \"\" as \"2006\": cannot parse \"\" as \"2006\""
#     }
#   ],
#   "data": null
# }

Metadata

Metadata

Assignees

Labels

kind/bugSomething is broken.priority/P0Critical issue that requires immediate attention.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions