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: if not kratos context then panic will result #1338

Merged
merged 2 commits into from
Aug 15, 2021
Merged

fix: if not kratos context then panic will result #1338

merged 2 commits into from
Aug 15, 2021

Conversation

fifsky
Copy link
Contributor

@fifsky fifsky commented Aug 14, 2021

当ctx不是kratos的context,则app.Name()会导致panic

当ctx不是kratos的context,则app.Name()会导致panic
@fifsky
Copy link
Contributor Author

fifsky commented Aug 14, 2021

场景,当使用kratos编写GRPC服务,而在其他项目中(比如gin的传统HTTP项目)使用kratos grpc client 和tracing middleware的时候,此时metadata里面获取的上下文就不是kratos,如果不判断,则会导致app.Name() panic

@codecov-commenter
Copy link

codecov-commenter commented Aug 15, 2021

Codecov Report

Merging #1338 (627b2d2) into main (c2b4d45) will increase coverage by 0.11%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1338      +/-   ##
==========================================
+ Coverage   62.91%   63.03%   +0.11%     
==========================================
  Files          61       61              
  Lines        2823     2824       +1     
==========================================
+ Hits         1776     1780       +4     
+ Misses        898      896       -2     
+ Partials      149      148       -1     
Impacted Files Coverage Δ
middleware/tracing/metadata.go 0.00% <0.00%> (ø)
config/config.go 54.66% <0.00%> (+5.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c2b4d45...627b2d2. Read the comment docs.

@daemon365
Copy link
Member

LGTM

@longXboy longXboy merged commit 80378ca into go-kratos:main Aug 15, 2021
@fifsky fifsky deleted the patch-1 branch August 15, 2021 09:58
zouyx pushed a commit to zouyx/kratos that referenced this pull request Aug 24, 2021
* fix: if not kratos context panic

当ctx不是kratos的context,则app.Name()会导致panic
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.

4 participants