Skip to content

fix nil pointer error on trace by id path#1441

Merged
joe-elliott merged 2 commits intografana:mainfrom
joe-elliott:nil-pointer-fix
May 24, 2022
Merged

fix nil pointer error on trace by id path#1441
joe-elliott merged 2 commits intografana:mainfrom
joe-elliott:nil-pointer-fix

Conversation

@joe-elliott
Copy link
Copy Markdown
Collaborator

What this PR does:

  • Moves the reference to resp to inside of the block where resp != nil
  • Adds additional guard code against resp.Header being nil.

Which issue(s) this PR fixes:
Fixes #1440

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
@joe-elliott joe-elliott marked this pull request as ready for review May 23, 2022 21:09
resp.Body = io.NopCloser(bytes.NewReader(traceBuffer))
}

if resp.Header != nil {
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.

The containing if statement also checks for http status OK. Does the header need to be set for errors as well? I'm honestly unsure.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I actually think this is better. Our errors tend to be just text so we probably shouldn't be setting the Content-Type header.

@joe-elliott joe-elliott merged commit d46f67a into grafana:main May 24, 2022
tanner-bruce pushed a commit to Shopify/tempo that referenced this pull request Aug 9, 2022
* fix nil pointer error on trace by id path

Signed-off-by: Joe Elliott <number101010@gmail.com>

* changelog

Signed-off-by: Joe Elliott <number101010@gmail.com>
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.

Trace query causes runtime error: invalid memory address or nil pointer dereference

3 participants