Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Avoid an NPE when parsing LogEvent responses #975

Merged
merged 1 commit into from
Mar 5, 2018

Conversation

squaremo
Copy link
Member

@squaremo squaremo commented Mar 5, 2018

We assume that if the upstream we're posting events to responds with
Content-Type: application/json, it must be a helpful error
(*github.com/weaveworks/flux/errors.Error). However, it's possible
to get any old JSON (even no JSON), and in that case, we'd trip
oursevles up by creating a helpful error with a nil pointer, leading
to a panic later.

We assume that if the upstream we're posting events to responds with
`Content-Type: application/json`, it must be a helpful error
(`*github.com/weaveworks/flux/errors.Error`). However, it's possible
to get any old JSON (even no JSON), and in that case, we'd trip
oursevles up by creating a helpful error with a nil pointer, leading
to a panic later.
@rade
Copy link
Contributor

rade commented Mar 5, 2018

Have we seen this in the wild? #949 and #958 perhaps?

@squaremo squaremo merged commit 6aced8e into master Mar 5, 2018
@squaremo
Copy link
Member Author

squaremo commented Mar 5, 2018

Have we seen this in the wild? #949 and #958 perhaps?

Not sure. I noticed it after adding a List resource to my test repo, rather than a CRD. It was provoked by the upstream server sending a 400 Bad Request in response to the posted sync event, and maybe that happens for CRDs too.

@squaremo squaremo deleted the issue/npe-event-post branch June 22, 2018 10:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants