Skip to content

Fix #16397: return 503 (UNAVAILABLE) instead of 404 (UNIMPLEMENTED) w… - #16398

Open
LI123456mo wants to merge 2 commits into
apache:3.3from
LI123456mo:fix-16397-status-code
Open

Fix #16397: return 503 (UNAVAILABLE) instead of 404 (UNIMPLEMENTED) w…#16398
LI123456mo wants to merge 2 commits into
apache:3.3from
LI123456mo:fix-16397-status-code

Conversation

@LI123456mo

Copy link
Copy Markdown
Contributor

Fixes part of #16397.

Problem

When pathResolver.resolve() fails to find an invoker because it was
unregistered during graceful shutdown, GrpcRequestHandlerMapping throws
a 404, which maps to gRPC UNIMPLEMENTED. Consumer-side cluster fault
tolerance treats UNIMPLEMENTED as a permanent, non-retriable error, so
it never fails over to another provider instance — turning a routine
rolling restart into a business-visible error.

Fix

When resolution fails specifically because the application is stopping
(ApplicationDeployer#isStopping()), return 503 instead of 404, which
maps to gRPC UNAVAILABLE — a retriable status consumers already know
how to fail over on.

Testing

Added GrpcRequestHandlerMappingTest#returnsServiceUnavailableWhenStoppingAndInvokerNotFound,
verifying a 503 is thrown when the app is stopping and resolution fails.

@codecov-commenter

codecov-commenter commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 60.87%. Comparing base (3a30432) to head (53bd596).

Files with missing lines Patch % Lines
...otocol/tri/h12/grpc/GrpcRequestHandlerMapping.java 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                3.3   #16398      +/-   ##
============================================
- Coverage     60.87%   60.87%   -0.01%     
+ Complexity    11766    11762       -4     
============================================
  Files          1953     1953              
  Lines         89273    89278       +5     
  Branches      13473    13474       +1     
============================================
+ Hits          54346    54347       +1     
- Misses        29333    29337       +4     
  Partials       5594     5594              
Flag Coverage Δ
integration-tests-java21 32.17% <33.33%> (+0.02%) ⬆️
integration-tests-java8 32.21% <33.33%> (+<0.01%) ⬆️
samples-tests-java21 32.19% <0.00%> (-0.01%) ⬇️
samples-tests-java8 29.84% <0.00%> (+0.04%) ⬆️
unit-tests-java11 59.14% <83.33%> (+0.02%) ⬆️
unit-tests-java17 58.60% <83.33%> (-0.04%) ⬇️
unit-tests-java21 58.63% <83.33%> (+0.02%) ⬆️
unit-tests-java25 58.56% <83.33%> (-0.01%) ⬇️
unit-tests-java8 59.16% <83.33%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants