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

fix nil pointer error on trace by id path #1441

Merged
merged 2 commits into from
May 24, 2022

Conversation

joe-elliott
Copy link
Member

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
@@ -161,14 +161,16 @@ func newTraceByIDMiddleware(cfg Config, logger log.Logger) Middleware {
}
resp.Body = io.NopCloser(bytes.NewReader(traceBuffer))
}

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