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(grpc): the unary server interceptor was already set and may not be reset #419

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

RomainMuller
Copy link
Contributor

There can be only one interceptor set by
grpc.[With](Unary|Stream)Interceptor, and a runtime error occurs if an interceptor is already defined and a second is attempted using the same API. Switch to using the chaining API, which appends to the existing list, and co-operates cleanly with the non-chained interceptor API.

Also, adjust the gRPC test to verify adequate behavior occurs.

Fixes #416

There can be only one interceptor set by
`grpc.[With](Unary|Stream)Interceptor`, and a runtime error occurs if an
interceptor is already defined and a second is attempted using the same
API. Switch to using the chaining API, which appends to the existing
list, and co-operates cleanly with the non-chained interceptor API.

Also, adjust the gRPC test to verify adequate behavior occurs.

Fixes #416
@RomainMuller RomainMuller requested a review from a team as a code owner November 25, 2024 11:11
@RomainMuller RomainMuller changed the title fix(grpc): use itnerceptor chaining API fix(grpc): the unary server interceptor was already set and may not be reset Nov 25, 2024
Comment on lines +55 to +56
assert.True(t, interceptedDirect.Load(), "original interceptor was not called")
assert.True(t, interceptedChain.Load(), "original chained interceptor was not called")
Copy link
Member

Choose a reason for hiding this comment

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

@RomainMuller Are the messages correct? If intercepted* are true, doesn't it mean they were called? The same for the same messages below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The message is for when it fails... But I'm a litle ambivalent as to whether they should mention what should've happened or what was observed that is a failure

Copy link
Member

Choose a reason for hiding this comment

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

Oh, you are right! I usually go with something like original interceptor expected a call, it didn't happen. Anyway, it's fine as long as it's understandable in the testing logs' context.

Comment on lines +55 to +56
assert.True(t, interceptedDirect.Load(), "original interceptor was not called")
assert.True(t, interceptedChain.Load(), "original chained interceptor was not called")
Copy link
Member

Choose a reason for hiding this comment

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

Oh, you are right! I usually go with something like original interceptor expected a call, it didn't happen. Anyway, it's fine as long as it's understandable in the testing logs' context.

@RomainMuller RomainMuller added this pull request to the merge queue Nov 25, 2024
@RomainMuller RomainMuller removed this pull request from the merge queue due to a manual request Nov 25, 2024
@RomainMuller RomainMuller added this pull request to the merge queue Nov 25, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 25, 2024
@RomainMuller RomainMuller added this pull request to the merge queue Nov 25, 2024
Merged via the queue into main with commit 7a1775c Nov 25, 2024
34 checks passed
@RomainMuller RomainMuller deleted the romain.marcadier/grpc-chain branch November 25, 2024 15:12
Copy link

codecov bot commented Nov 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.67%. Comparing base (9178229) to head (3787f21).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #419      +/-   ##
==========================================
+ Coverage   63.97%   64.67%   +0.70%     
==========================================
  Files         180      180              
  Lines       10894    10924      +30     
==========================================
+ Hits         6969     7065      +96     
+ Misses       3401     3314      -87     
- Partials      524      545      +21     
Components Coverage Δ
Generators 76.69% <ø> (ø)
Instruments 73.41% <ø> (ø)
Go Driver 80.16% <ø> (ø)
Toolexec Driver 73.59% <ø> (ø)
Aspects 78.57% <ø> (ø)
Injector 77.13% <ø> (ø)
Job Server 73.23% <ø> (+5.24%) ⬆️
Integration Test Suite 57.35% <100.00%> (+0.22%) ⬆️
Other 64.67% <100.00%> (+0.70%) ⬆️
Files with missing lines Coverage Δ
_integration-tests/tests/grpc/grpc.go 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

---- 🚨 Try these New Features:

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.

[BUG] Grpc interceptor strategy does not work if there is an existing interceptor
2 participants