Skip to content

[usage] Fix report to JSON conversion #12545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 31, 2022
Merged

Conversation

easyCZ
Copy link
Member

@easyCZ easyCZ commented Aug 31, 2022

Description

Upload of usage report fails with "failed to marshal report to JSON: json: error calling MarshalJSON for type db.VarcharTime: unexpected end of JSON input", this fixes that issue.

Related Issue(s)

Fixes #

How to test

Release Notes

NONE

Documentation

Werft options:

  • /werft with-preview

@easyCZ easyCZ force-pushed the mp/usage-fix-report-json branch from 4a5ab24 to 56c1b01 Compare August 31, 2022 12:24
@roboquat roboquat added size/L and removed size/M labels Aug 31, 2022
@easyCZ easyCZ marked this pull request as ready for review August 31, 2022 12:34
@easyCZ easyCZ requested a review from a team August 31, 2022 12:34
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Aug 31, 2022
Copy link
Contributor

@andrew-farries andrew-farries left a comment

Choose a reason for hiding this comment

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

What caused the uploads to start failing? Incorrect marshalling of nil values?

return n.Time().UTC().MarshalJSON()
}

func (n *VarcharTime) UnmarshalJSON(data []byte) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Was adding this method necessary to fix the upload or just for the round-trip test?

Copy link
Member Author

Choose a reason for hiding this comment

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

Was necessary for the report download to serialise correctly. We'd convert it into a string, but on unmarshal we'd try to put it into the VarcharTime struct which would fail

@roboquat roboquat merged commit dd6cdf9 into main Aug 31, 2022
@roboquat roboquat deleted the mp/usage-fix-report-json branch August 31, 2022 12:39
@easyCZ
Copy link
Member Author

easyCZ commented Aug 31, 2022

What caused the uploads to start failing? Incorrect marshalling of nil values?

It was caused by marshalling "invalid" VarcharTime structs. Instances which would have the 0 timestamp and set the flag "invalid". This was because serializing as "" was not accepted by the json.Marshaller interface

@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note-none size/L team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants