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(zipkin): avoid getting a nil value in log phase(#10590) #10666

Merged
merged 2 commits into from
Dec 22, 2023

Conversation

junhao69535
Copy link
Contributor

Description

An error(attempt to index local 'opentracing' (a nil value)) occurs in the following situations:

  • failed to parse b3 header and return 400.
  • plugins with higher priority return or throw exceptions.

All of the above result in a not being assigned value to ctx.opentracing. so got a error in log phase. this pr will fix it.

Fixes #10590

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

--- more_headers
b3: abc
--- no_error_log
[error]
Copy link
Contributor

Choose a reason for hiding this comment

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

u can insert a new line at here to help the ci works

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, thk

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Vacant2333
my new test cast as following:

=== TEST 23: no error in log phase while b3 header invalid
--- request
GET /echo
--- more_headers
b3: 80f198ee56343ba864fe8b2a57d3eff7
--- response_headers
x-b3-sampled:
--- error_code: 400
--- grep_error_log eval
qr/attempt to index local 'opentracing' \(a nil value\)
--- grep_error_log_out

i want to assert that there is no corresponding error in the log, what should I do?

Copy link
Contributor

Choose a reason for hiding this comment

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

u may need to try this https://apisix.apache.org/docs/apisix/internal/testing-framework/#executing-shell-commands, im not sure if it will works🤣, i didnt find some testcase need to do like u want

Copy link
Contributor

Choose a reason for hiding this comment

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

i want to assert that there is no corresponding error in the log, what should I do?

You can use no_error_log https://github.com/apache/apisix/blob/master/docs/en/latest/plugin-develop.md?plain=1#L549

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i want to assert that there is no corresponding error in the log, what should I do?

You can use no_error_log https://github.com/apache/apisix/blob/master/docs/en/latest/plugin-develop.md?plain=1#L549

there is a error in rewrite phase, but no error in log phase.

@monkeyDluffy6017 monkeyDluffy6017 merged commit 06aa250 into apache:master Dec 22, 2023
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: attempt to index local 'opentracing' (a nil value) when using zipkin plugin
6 participants