Skip to content

jsonpatcher: empty interface timestamp#439

Merged
sanderpick merged 2 commits intomasterfrom
sander/handle-old-ts
Sep 18, 2020
Merged

jsonpatcher: empty interface timestamp#439
sanderpick merged 2 commits intomasterfrom
sander/handle-old-ts

Conversation

@sanderpick
Copy link
Copy Markdown
Contributor

See #416 (comment)

After trying a few different ways to fix this, I landed on just using interface{} for Timestamp, which allows us to continue bulk-decoding events with potentially mixed Timestamp types.

Signed-off-by: Sander Pick <sanderpick@gmail.com>
@sanderpick sanderpick self-assigned this Sep 18, 2020
Signed-off-by: Sander Pick <sanderpick@gmail.com>
Copy link
Copy Markdown
Contributor

@jsign jsign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! with a comment.

switch ts := je.Timestamp.(type) {
case time.Time:
t = ts
case int:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should s/int/int64 considering symmetry with Time() switch case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did that initially, but the type actually comes back as int when it's set on an empty interface value.

@sanderpick sanderpick merged commit 771a545 into master Sep 18, 2020
@sanderpick sanderpick deleted the sander/handle-old-ts branch September 18, 2020 19:53
@sanderpick sanderpick mentioned this pull request Sep 18, 2020
@requilence
Copy link
Copy Markdown
Contributor

requilence commented Sep 21, 2020

@sanderpick I've just tested this fix and and now I got the gob encode error for old-format time in the dispatcher.Dispatch() : gob: type not registered for interface: map[string]interface {}

So looks like empty time.Time decoded into map[string]interface which is not auto-registred in the gob

I've made the issue to track it: #443 443

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants