[v20.07.0-beta.Jun22] time.UnmarshalBinary: unsupported version

Is there a short script or description of the events that lead you to reproduce this issue. I think I can guess some of them but I want to be sure.

In the meantime, I searched for the error and the error is being thrown by the time standard library, not by Dgraph.

This is the code in question:

	if buf[0] != timeBinaryVersion {
		return errors.New("Time.UnmarshalBinary: unsupported version")
	}

timeBinaryVersion is a constant set to 1. So this function expects the first byte to be 1. I think the problem is that UnmarshalBinary does not expect a byte containing the string representation of a date. It expects a byte slice in the format outputted by time - The Go Programming Language.

so the code should be:

binaryTime, err := time.Now().MarshalBinary()
....

&api.Facet{
    Key:     "scheduled_at",
    Value:   binaryTime,
    ValType: api.Facet_DATETIME,
},
2 Likes