Skip to content
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

Upgrade BurntSushi/toml to avoid decoding bug #26

Merged
merged 4 commits into from Oct 31, 2022
Merged

Conversation

lackstein
Copy link
Member

There's a bug (see BurntSushi/toml#339) in BurnSushi/toml v0.4.1 that was causing empty arrays to be decoded into a nil interface.

If you print out the interface it looks correct:

map[args:[[]] custom:map[expires_in:5m] queue:default retry:0 type:analysisWatchdog]

But when you marshal it into JSON:

{"args":[null],"custom":{"expires_in":"5m"},"jobtype":"analysisWatchdog","queue":"default","retry":0,"type":"analysisWatchdog"}

Looking at the interface with spew it's clear that the inner array in args is nil:

(map[string]interface {}) (len=5) {
 (string) (len=4) "type": (string) (len=16) "analysisWatchdog",
 (string) (len=5) "queue": (string) (len=7) "default",
 (string) (len=5) "retry": (int64) 0,
 (string) (len=4) "args": ([]interface {}) (len=1 cap=1) {
  ([]interface {}) <nil>
 },
 (string) (len=6) "custom": (map[string]interface {}) (len=1) {
  (string) (len=10) "expires_in": (string) (len=2) "5m"
 }
}

@lackstein lackstein requested review from a team and elldritch and removed request for a team October 31, 2022 18:18
Copy link
Member

@elldritch elldritch left a comment

Choose a reason for hiding this comment

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

Good call on the linting fixes too.

FYI, the maximally reliable way to determine the real shape of data is fmt.Printf using the %#v verb.

go.mod Outdated Show resolved Hide resolved
@lackstein lackstein merged commit 87d22d1 into main Oct 31, 2022
@lackstein lackstein deleted the nl/upgrade-toml branch October 31, 2022 19:57
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.

None yet

2 participants