Skip to content

Log raw graphql responses when they don't unmarshal correctly#3

Open
alichay wants to merge 2 commits intomasterfrom
bugfix/log-unparseable-errors
Open

Log raw graphql responses when they don't unmarshal correctly#3
alichay wants to merge 2 commits intomasterfrom
bugfix/log-unparseable-errors

Conversation

@alichay
Copy link
Copy Markdown

@alichay alichay commented Mar 8, 2023

When the json output doesn't match the struct layout, it prints the raw json response in the error for debugging reasons.

The response pretty-prints and indents the json with a pipe symbol, it looks something like this:

Error: decoding response
 | {
 |     "error": "some error string",
 |     "code": 10,
 | }
error: json: cannot unmarshal object into Go struct field [xyz] of type [jkl]

(it used to be Error: decoding response: json: cannot unmarshal object into Go struct field[xyz] of type [jkl])

Relevant context: superfly/flyctl#1866

Copy link
Copy Markdown

@yogeshgadge yogeshgadge left a comment

Choose a reason for hiding this comment

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

IMO it should not print anything and treat as logf potentially including granular level type = ERROR. This is because others might want logs written in their own fashion. There is a convenient Log hook for that.

I might suggest using c.logf

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.

2 participants