-
Notifications
You must be signed in to change notification settings - Fork 2.4k
[GRPC] Add handling for the grpc.detailed_errors.enabled setting and global gRPC error_trace parameter #19644
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
base: main
Are you sure you want to change the base?
[GRPC] Add handling for the grpc.detailed_errors.enabled setting and global gRPC error_trace parameter #19644
Conversation
…andling Signed-off-by: Sergei Ustimenko <[email protected]>
…setting for gRPC Signed-off-by: Sergei Ustimenko <[email protected]>
Signed-off-by: Sergei Ustimenko <[email protected]>
|
❌ Gradle check result for 702f7d9: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Sergei Ustimenko <[email protected]>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #19644 +/- ##
============================================
+ Coverage 73.20% 73.28% +0.07%
- Complexity 71745 71801 +56
============================================
Files 5795 5796 +1
Lines 328304 328341 +37
Branches 47283 47284 +1
============================================
+ Hits 240334 240615 +281
+ Misses 68663 68463 -200
+ Partials 19307 19263 -44 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Sergei Ustimenko <[email protected]>
|
❌ Gradle check result for 9b42790: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Looks like a failure due to a flaky test, more here: #14312 |
|
Hi folks, this PR is ready for review, could someone please take a look? Thanks a lot! |
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/GrpcErrorHandler.java
Outdated
Show resolved
Hide resolved
The CI can be rerun by closing/re-opening the PR, or pushing an empty commit. (Or by resolving conflicts which creates a merge commit) |
Signed-off-by: Sergei Ustimenko <[email protected]>
…ror-handling-setting
Signed-off-by: Sergei Ustimenko <[email protected]>
…ror-handling-setting
Signed-off-by: Sergei Ustimenko <[email protected]>
Signed-off-by: Sergei Ustimenko <[email protected]>
Signed-off-by: Sergei Ustimenko <[email protected]>
|
❌ Gradle check result for f6d8f9a: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
karenyrx
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side question: Do we also eventually plan for support for REST_EXCEPTION_SKIP_STACK_TRACE as well?
...ain/java/org/opensearch/transport/grpc/proto/response/exceptions/ResponseHandlingParams.java
Outdated
Show resolved
Hide resolved
...ain/java/org/opensearch/transport/grpc/proto/response/exceptions/ResponseHandlingParams.java
Outdated
Show resolved
Hide resolved
...s/transport-grpc/src/main/java/org/opensearch/transport/grpc/services/SearchServiceImpl.java
Outdated
Show resolved
Hide resolved
...ain/java/org/opensearch/transport/grpc/proto/response/exceptions/ResponseHandlingParams.java
Outdated
Show resolved
Hide resolved
...ain/java/org/opensearch/transport/grpc/proto/response/exceptions/ResponseHandlingParams.java
Outdated
Show resolved
Hide resolved
@karenyrx, good question. What would be use cases here and what an implementation might look like? |
Signed-off-by: Sergei Ustimenko <[email protected]>
4ba8567 to
a5a64e3
Compare
📝 WalkthroughWalkthroughAdds a server-side gRPC detailed-errors setting and a GrpcParamsHandler; threads request-level GlobalParams through services, listeners, error handling, and proto converters to control inclusion of stack traces and error details; updates plugin settings exposure and many tests. Changes
sequenceDiagram
participant Client
participant Service as gRPC_Service
participant Params as GrpcParamsHandler
participant Listener
participant Error as GrpcErrorHandler
participant Proto as ProtoUtils
Client->>Service: Send request (includes GlobalParams.error_trace)
Service->>Params: validateStackTraceDetailsConfiguration(GlobalParams)
alt request allowed
Service->>Listener: create listener(with GlobalParams)
Listener->>Proto: toProto(response, GlobalParams)
Listener-->>Client: stream proto response
else request invalid
Service->>Error: convertToGrpcError(exception, GlobalParams)
Error->>Params: isDetailedStackTraceRequested(GlobalParams)
Error->>Proto: generate error proto with/without traces
Error-->>Client: return error
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
Comment |
…ror-handling-setting Signed-off-by: Sergei Ustimenko <[email protected]>
5ceb0ee to
2907384
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/ShardOperationFailedExceptionProtoUtils.java (1)
48-50: Minor typo: Missing space in error message.There's a missing space before "cannot" in the error message.
default -> throw new UnsupportedOperationException( - "Unsupported ShardOperationFailedException " + exception.getClass().getName() + "cannot be converted to proto." + "Unsupported ShardOperationFailedException " + exception.getClass().getName() + " cannot be converted to proto." );
🧹 Nitpick comments (12)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/GrpcPluginTests.java (1)
147-147: Consider adding an explicit assertion for the new setting.The count was updated to 14 to account for
SETTING_GRPC_DETAILED_ERRORS_ENABLED, but unlike other settings, there's no explicitassertTruecheck verifying it's included. This could mask issues if the setting is accidentally removed later.assertTrue("SETTING_GRPC_KEEPALIVE_TIMEOUT should be included", settings.contains(SETTING_GRPC_KEEPALIVE_TIMEOUT)); + assertTrue("SETTING_GRPC_DETAILED_ERRORS_ENABLED should be included", settings.contains(Netty4GrpcServerTransport.SETTING_GRPC_DETAILED_ERRORS_ENABLED)); // Verify the number of settings assertEquals("Should return 14 settings", 14, settings.size());modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/document/bulk/BulkResponseProtoUtils.java (1)
38-56: LGTM - GlobalParams correctly threaded through bulk response conversion.The
paramsargument is properly propagated toBulkItemResponseProtoUtils.toProto(), enabling consistent error_trace handling for each bulk item's error cause.Minor cleanup: Consider removing the commented-out debug statement on line 39.
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/document/common/ShardInfoProtoUtilsTests.java (1)
22-23: LGTM - Tests updated to match new API signature.The test cases correctly use
GLOBAL_PARAMS_WITH_ERROR_TRACE_FALSEfor the updatedtoProto()signature.Consider adding a test case with
GLOBAL_PARAMS_WITH_ERROR_TRACE_TRUEfor thetestToProtoWithFailuresscenario to verify that stack traces are included in the shard failure reasons when error_trace is enabled.Also applies to: 31-31, 60-60, 92-92
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/listeners/SearchRequestActionListenerTests.java (1)
37-37: Consider using TestFixtures constants for consistency.The listener is initialized with
GlobalParams.newBuilder().build(). For consistency with other tests and clarity, consider usingTestFixtures.GLOBAL_PARAMS_WITH_ERROR_TRACE_FALSE(which is equivalent sinceerrorTracedefaults tofalse).+import static org.opensearch.transport.grpc.TestFixtures.GLOBAL_PARAMS_WITH_ERROR_TRACE_FALSE; ... - listener = new SearchRequestActionListener(responseObserver, GlobalParams.newBuilder().build()); + listener = new SearchRequestActionListener(responseObserver, GLOBAL_PARAMS_WITH_ERROR_TRACE_FALSE);modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/TestFixtures.java (1)
14-24: Add private constructor to complete utility class pattern.The class is correctly marked
final, but a private constructor should be added to prevent instantiation, following the utility class pattern used throughout this codebase.public final class TestFixtures { + private TestFixtures() { + // Utility class, no instances + } + public static final GlobalParams GLOBAL_PARAMS_WITH_ERROR_TRACE_TRUE = GlobalParams.newBuilder().setErrorTrace(true).build();modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/listeners/SearchRequestActionListener.java (1)
39-43: Consider adding null-check forparamsparameter.The constructor stores
paramswithout validation, but bothonResponseandonFailurepaths use it. If a caller passesnull, this would cause an NPE whenSearchResponseProtoUtils.toProtoorGrpcErrorHandler.convertToGrpcErroris invoked.public SearchRequestActionListener(StreamObserver<org.opensearch.protobufs.SearchResponse> responseObserver, GlobalParams params) { super(); + if (params == null) { + throw new IllegalArgumentException("params cannot be null"); + } this.responseObserver = responseObserver; this.params = params; }modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/document/common/ShardInfoProtoUtils.java (1)
52-60: Missing@paramdocumentation forparams.The Javadoc for the private
toProtomethod is missing the@param paramsentry to match the updated method signature./** * Converts a ReplicationResponse.ShardInfo.Failure Java object to a protobuf ShardFailure. * Similar to {@link ReplicationResponse.ShardInfo.Failure#toXContent(XContentBuilder, ToXContent.Params)} * * @param failure The shard failure to convert to protobuf format + * @param params The global gRPC request parameters * @return The protobuf representation of the shard failure * @throws IOException If there's an error during conversion */ private static ShardFailure toProto(ReplicationResponse.ShardInfo.Failure failure, GlobalParams params) throws IOException {modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/util/GrpcParamsHandlerTests.java (1)
35-43: Simplify the validation pass test.Using try-catch with
fail()is verbose. SincevalidateStackTraceDetailsConfigurationdoesn't return a value, simply calling it without catching exceptions is sufficient—the test framework will fail if an unexpected exception is thrown.public void testValidationPassesWhenDetailedErrorsDisabledAndClientDoesNotRequestStackTrace() { GrpcParamsHandler.initialize(settingsWithGivenStackTraceConfig(false)); - - try { - GrpcParamsHandler.validateStackTraceDetailsConfiguration(GLOBAL_PARAMS_WITH_ERROR_TRACE_FALSE); - } catch (Exception e) { - fail("Validation should pass without exceptions when stack traces are not requested."); - } + // Should not throw - test framework will fail if exception is thrown + GrpcParamsHandler.validateStackTraceDetailsConfiguration(GLOBAL_PARAMS_WITH_ERROR_TRACE_FALSE); }modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/services/SearchServiceImplTests.java (2)
44-55: Redundant@Afterreset when@Beforealready initializes.Both
@Beforeand@AftercallGrpcParamsHandler.initialize(settingsWithGivenStackTraceConfig(true)). Since@Beforeruns before each test, the@Afterreset is unnecessary unless there's a concern about test class cleanup affecting other test classes sharing static state.If the intent is to ensure clean state for other test classes, consider adding a clarifying comment. Otherwise, the
@Aftermethod can be removed since@Beforealready handles initialization.
117-130: Misleading variable name in passing test case.The variable
serviceThatFailsToProvideErrorInfois used in both tests, but its name only accurately describes the first test's scenario. In this test, validation passes and the service operates normally.public void testErrorTraceConfigValidationPassesWhenServerSettingIsDisabledAndRequestSkipsStackTrace() { // Setup request and the service, server setting is off and request skips a stack trace SearchRequest request = createTestSearchRequest().toBuilder() .setGlobalParams(org.opensearch.protobufs.GlobalParams.newBuilder().setErrorTrace(false)) .build(); GrpcParamsHandler.initialize(settingsWithGivenStackTraceConfig(false)); - SearchServiceImpl serviceThatFailsToProvideErrorInfo = new SearchServiceImpl(client, queryUtils); + SearchServiceImpl serviceWithErrorTracingDisabled = new SearchServiceImpl(client, queryUtils); // Call search method - serviceThatFailsToProvideErrorInfo.search(request, responseObserver); + serviceWithErrorTracingDisabled.search(request, responseObserver); // Verify that client.search was called verify(client).search(any(org.opensearch.action.search.SearchRequest.class), any()); }modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/GrpcErrorHandler.java (1)
52-57: Incomplete Javadoc forparamsparameter.The
@param paramsdocumentation is incomplete—it should describe what the parameter controls (e.g., "The global gRPC request parameters used to control error detail level").* @param e The exception to convert - * @param params + * @param params The global gRPC request parameters controlling error detail level (e.g., stack trace inclusion) * @return StatusRuntimeException with appropriate gRPC status and enhanced error detailsmodules/transport-grpc/src/test/java/org/opensearch/transport/grpc/util/GrpcErrorHandlerTests.java (1)
449-455: Consider adding a two-argument test for null exception handling.This test uses the single-argument overload
convertToGrpcError(null), while all other tests use the two-argument form. For completeness, consider adding a test that verifies null exception handling with the two-argument form as well, ensuring consistent behavior regardless of which overload is used.public void testNullExceptionConversionWithGlobalParams() { StatusRuntimeException result = GrpcErrorHandler.convertToGrpcError(null, GLOBAL_PARAMS_WITH_ERROR_TRACE_FALSE); assertEquals(Status.INTERNAL.getCode(), result.getStatus().getCode()); assertEquals("INTERNAL: Unexpected null exception", result.getMessage()); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (38)
CHANGELOG.md(1 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/GrpcPlugin.java(6 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/Netty4GrpcServerTransport.java(1 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/listeners/BulkRequestActionListener.java(4 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/listeners/SearchRequestActionListener.java(2 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/document/bulk/BulkItemResponseProtoUtils.java(3 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/document/bulk/BulkResponseProtoUtils.java(3 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/document/common/DocWriteResponseProtoUtils.java(3 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/document/common/ShardInfoProtoUtils.java(3 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/opensearchexception/OpenSearchExceptionProtoUtils.java(8 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/DefaultShardOperationFailedExceptionProtoUtils.java(6 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/ReplicationResponseShardInfoFailureProtoUtils.java(3 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/ShardOperationFailedExceptionProtoUtils.java(2 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/ShardSearchFailureProtoUtils.java(2 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/SnapshotShardFailureProtoUtils.java(2 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/search/ProtoActionsProtoUtils.java(3 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/search/SearchResponseProtoUtils.java(4 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/search/ShardStatisticsProtoUtils.java(4 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/services/DocumentServiceImpl.java(2 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/services/SearchServiceImpl.java(2 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/GrpcErrorHandler.java(8 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/GrpcParamsHandler.java(1 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/GrpcPluginTests.java(1 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/TestFixtures.java(1 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/listeners/BulkRequestActionListenerTests.java(2 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/listeners/SearchRequestActionListenerTests.java(3 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/BulkResponseProtoUtilsTests.java(4 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/document/bulk/BulkItemResponseProtoUtilsTests.java(8 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/document/common/DocWriteResponseProtoUtilsTests.java(5 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/document/common/ShardInfoProtoUtilsTests.java(3 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/exceptions/OpenSearchExceptionProtoUtilsTests.java(11 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/DefaultShardOperationFailedExceptionProtoUtilsTests.java(6 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/ShardOperationFailedExceptionProtoUtilsTests.java(6 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/search/SearchResponseProtoUtilsTests.java(8 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/services/SearchServiceImplTests.java(5 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/services/document/DocumentServiceImplTests.java(5 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/util/GrpcErrorHandlerTests.java(16 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/util/GrpcParamsHandlerTests.java(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (23)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/ShardOperationFailedExceptionProtoUtilsTests.java (2)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/TestFixtures.java (1)
TestFixtures(14-24)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/ShardOperationFailedExceptionProtoUtils.java (1)
ShardOperationFailedExceptionProtoUtils(25-53)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/document/bulk/BulkResponseProtoUtils.java (1)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/document/bulk/BulkItemResponseProtoUtils.java (1)
BulkItemResponseProtoUtils(31-98)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/document/common/DocWriteResponseProtoUtils.java (1)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/document/common/ShardInfoProtoUtils.java (1)
ShardInfoProtoUtils(23-70)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/SnapshotShardFailureProtoUtils.java (1)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/opensearchexception/OpenSearchExceptionProtoUtils.java (1)
OpenSearchExceptionProtoUtils(50-273)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/BulkResponseProtoUtilsTests.java (2)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/TestFixtures.java (1)
TestFixtures(14-24)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/document/bulk/BulkResponseProtoUtils.java (1)
BulkResponseProtoUtils(23-80)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/listeners/BulkRequestActionListenerTests.java (1)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/TestFixtures.java (1)
TestFixtures(14-24)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/document/bulk/BulkItemResponseProtoUtilsTests.java (2)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/TestFixtures.java (1)
TestFixtures(14-24)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/document/bulk/BulkItemResponseProtoUtils.java (1)
BulkItemResponseProtoUtils(31-98)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/search/ProtoActionsProtoUtils.java (1)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/search/ShardStatisticsProtoUtils.java (1)
ShardStatisticsProtoUtils(27-69)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/services/document/DocumentServiceImplTests.java (2)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/GrpcParamsHandler.java (1)
GrpcParamsHandler(30-82)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/TestFixtures.java (1)
TestFixtures(14-24)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/GrpcErrorHandler.java (3)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/GrpcParamsHandler.java (1)
GrpcParamsHandler(30-82)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/RestToGrpcStatusConverter.java (1)
RestToGrpcStatusConverter(18-152)libs/core/src/main/java/org/opensearch/ExceptionsHelper.java (1)
ExceptionsHelper(76-476)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/GrpcPlugin.java (2)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/GrpcParamsHandler.java (1)
GrpcParamsHandler(30-82)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/Netty4GrpcServerTransport.java (1)
Netty4GrpcServerTransport(64-501)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/services/SearchServiceImpl.java (2)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/GrpcParamsHandler.java (1)
GrpcParamsHandler(30-82)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/GrpcErrorHandler.java (1)
GrpcErrorHandler(36-225)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/services/SearchServiceImplTests.java (2)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/GrpcParamsHandler.java (1)
GrpcParamsHandler(30-82)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/TestFixtures.java (1)
TestFixtures(14-24)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/listeners/SearchRequestActionListener.java (2)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/search/SearchResponseProtoUtils.java (1)
SearchResponseProtoUtils(25-208)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/GrpcErrorHandler.java (1)
GrpcErrorHandler(36-225)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/ReplicationResponseShardInfoFailureProtoUtils.java (1)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/opensearchexception/OpenSearchExceptionProtoUtils.java (1)
OpenSearchExceptionProtoUtils(50-273)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/search/SearchResponseProtoUtilsTests.java (2)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/TestFixtures.java (1)
TestFixtures(14-24)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/search/SearchResponseProtoUtils.java (1)
SearchResponseProtoUtils(25-208)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/TestFixtures.java (1)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/Netty4GrpcServerTransport.java (1)
Netty4GrpcServerTransport(64-501)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/DefaultShardOperationFailedExceptionProtoUtils.java (1)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/opensearchexception/OpenSearchExceptionProtoUtils.java (1)
OpenSearchExceptionProtoUtils(50-273)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/search/ShardStatisticsProtoUtils.java (1)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/ShardOperationFailedExceptionProtoUtils.java (1)
ShardOperationFailedExceptionProtoUtils(25-53)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/util/GrpcParamsHandlerTests.java (1)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/TestFixtures.java (1)
TestFixtures(14-24)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/opensearchexception/OpenSearchExceptionProtoUtils.java (2)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/GrpcParamsHandler.java (1)
GrpcParamsHandler(30-82)libs/core/src/main/java/org/opensearch/ExceptionsHelper.java (1)
ExceptionsHelper(76-476)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/document/common/ShardInfoProtoUtilsTests.java (2)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/TestFixtures.java (1)
TestFixtures(14-24)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/document/common/ShardInfoProtoUtils.java (1)
ShardInfoProtoUtils(23-70)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/exceptions/OpenSearchExceptionProtoUtilsTests.java (2)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/TestFixtures.java (1)
TestFixtures(14-24)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/opensearchexception/OpenSearchExceptionProtoUtils.java (1)
OpenSearchExceptionProtoUtils(50-273)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
- GitHub Check: gradle-check
- GitHub Check: assemble (25, windows-latest)
- GitHub Check: assemble (21, ubuntu-latest)
- GitHub Check: assemble (25, ubuntu-latest)
- GitHub Check: assemble (21, ubuntu-24.04-arm)
- GitHub Check: assemble (25, ubuntu-24.04-arm)
- GitHub Check: assemble (21, windows-latest)
- GitHub Check: precommit (21, windows-latest)
- GitHub Check: precommit (25, macos-15-intel)
- GitHub Check: precommit (25, ubuntu-latest)
- GitHub Check: precommit (25, macos-15)
- GitHub Check: precommit (21, windows-2025, true)
- GitHub Check: precommit (21, ubuntu-24.04-arm)
- GitHub Check: precommit (25, ubuntu-24.04-arm)
- GitHub Check: precommit (21, macos-15)
- GitHub Check: precommit (25, windows-latest)
- GitHub Check: precommit (21, ubuntu-latest)
- GitHub Check: precommit (21, macos-15-intel)
- GitHub Check: Analyze (java)
🔇 Additional comments (61)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/document/bulk/BulkItemResponseProtoUtilsTests.java (2)
33-34: LGTM!The static import for
GLOBAL_PARAMS_WITH_ERROR_TRACE_FALSEfromTestFixturesprovides a clean way to supply the requiredGlobalParamsparameter across all test cases.
52-55: Consistent update to the new method signature.All
toProtocalls are correctly updated to passGLOBAL_PARAMS_WITH_ERROR_TRACE_FALSE, aligning with the production code's new signature that requiresGlobalParamsfor error trace control.modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/ShardOperationFailedExceptionProtoUtilsTests.java (2)
24-24: LGTM!Static import added consistently with other test files in this PR.
136-144: Single-argumenttoProtooverload exists and the test is valid.The test code compiles successfully as shown in the final state, confirming the single-argument
toProto(ShardOperationFailedException)overload is present. No action required.modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/document/common/DocWriteResponseProtoUtilsTests.java (1)
20-21: LGTM!Import and test updates are consistent with the pattern established across other test files in this PR.
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/BulkResponseProtoUtilsTests.java (1)
25-26: LGTM!Consistent with the GlobalParams propagation pattern across all updated test files.
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/document/common/DocWriteResponseProtoUtils.java (3)
13-13: LGTM!Import added for the new
GlobalParamsparameter type.
35-39: Proper Javadoc and signature update for GlobalParams threading.The method signature correctly includes the
GlobalParamsparameter with appropriate documentation. This enables error trace control to propagate through the proto conversion chain.
61-61: Correct propagation of GlobalParams to downstream conversion.
GlobalParamsis properly passed toShardInfoProtoUtils.toProto, which (per the relevant code snippet) uses it when generating error causes viaOpenSearchExceptionProtoUtils.generateThrowableProto. This ensures consistent error trace behavior for shard failure information.modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/Netty4GrpcServerTransport.java (1)
190-200: Well-structured setting definition with clear documentation.The new
SETTING_GRPC_DETAILED_ERRORS_ENABLEDsetting follows the established pattern for gRPC transport settings. The Javadoc clearly explains the interaction between this server-side setting and the per-requesterror_traceparameter, which matches the PR's stated objectives for parity with HTTP behavior. Verify that this setting is consumed inGrpcParamsHandleror the relevant error handling implementation.modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/GrpcPlugin.java (3)
189-189: LGTM - GrpcParamsHandler initialization properly wired.The initialization call correctly precedes transport and service creation, ensuring the handler is configured before any gRPC request processing occurs.
241-241: Consistent initialization in secure transport path.Matches the non-secure path initialization pattern, ensuring both transport types respect the
grpc.detailed_errors.enabledsetting.
291-292: Setting correctly exposed via getSettings().The new
SETTING_GRPC_DETAILED_ERRORS_ENABLEDis properly registered, allowing OpenSearch to recognize and validate the setting at node startup.modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/listeners/BulkRequestActionListenerTests.java (1)
26-26: LGTM - Listener test properly updated for new constructor signature.The test correctly passes
GLOBAL_PARAMS_WITH_ERROR_TRACE_FALSEto the listener constructor, aligning with the production code changes.Also applies to: 41-41
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/ReplicationResponseShardInfoFailureProtoUtils.java (1)
36-48: LGTM - GlobalParams correctly propagated for error reason generation.The
paramsargument is properly passed togenerateThrowableProto(), ensuring stack trace inclusion respects theerror_tracesetting when generating the shard failure reason.modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/ShardSearchFailureProtoUtils.java (1)
36-44: LGTM - GlobalParams correctly propagated for search failure reason generation.The
paramsargument is properly passed togenerateThrowableProto(), ensuring consistent error_trace handling for shard search failures.modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/search/SearchResponseProtoUtilsTests.java (1)
24-24: LGTM - Consistent GlobalParams propagation in tests.The test updates correctly align with the new
toProto(SearchResponse, GlobalParams)API signature. All tests consistently useGLOBAL_PARAMS_WITH_ERROR_TRACE_FALSE.Consider adding a test case with
GLOBAL_PARAMS_WITH_ERROR_TRACE_TRUEto verify behavior when error traces are enabled, particularly for scenarios involving shard failures where theGlobalParamswould affect error serialization.Also applies to: 45-48
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/services/DocumentServiceImpl.java (1)
46-56: LGTM - Proper GlobalParams validation and propagation.The implementation correctly:
- Validates stack trace configuration early (fail-fast pattern)
- Propagates
GlobalParamsto both the listener and error handler- Handles validation failures through the existing exception path
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/ShardOperationFailedExceptionProtoUtils.java (1)
39-44: LGTM - Consistent GlobalParams propagation through exception handling.The
GlobalParamsparameter is correctly propagated to all specialized exception proto utilities through the switch expression.modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/listeners/SearchRequestActionListenerTests.java (1)
62-71: LGTM - Test correctly validates failure handling.The test properly verifies that
onFailuretriggersonErrorwith aStatusRuntimeException. The refactoring to use the class-levelresponseObserveris cleaner.modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/search/ProtoActionsProtoUtils.java (1)
43-54: LGTM - Clean GlobalParams propagation.The
GlobalParamsparameter is correctly added to the method signature and propagated toShardStatisticsProtoUtils.getShardStats, enabling error trace control for shard failure serialization.modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/search/SearchResponseProtoUtils.java (1)
40-44: LGTM - Proper GlobalParams threading through search response conversion.The
GlobalParamsis correctly propagated through the conversion chain toProtoActionsProtoUtils.buildBroadcastShardsHeader, enabling proper error trace control for shard failures in search responses.Also applies to: 88-97
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/services/SearchServiceImpl.java (1)
60-75: LGTM - Consistent implementation with proper error handling.The implementation correctly:
- Validates stack trace configuration early via
GrpcParamsHandler.validateStackTraceDetailsConfiguration- Propagates
GlobalParamsto the listener and error handler- Handles both
RuntimeExceptionandIOExceptionappropriatelyThis aligns well with
DocumentServiceImpland the broaderGlobalParamspropagation pattern.modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/SnapshotShardFailureProtoUtils.java (1)
36-49: Null-safety improvements and GlobalParams propagation look good.The addition of null checks for
index()andnodeId()(lines 38-45) is a good defensive practice. The method signature correctly propagatesGlobalParamsto control error detail level, aligning with the broader PR changes.modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/document/bulk/BulkItemResponseProtoUtils.java (1)
48-70: LGTM! GlobalParams propagation is correctly implemented.The
GlobalParamsparameter is properly passed to bothDocWriteResponseProtoUtils.toProtofor success cases andOpenSearchExceptionProtoUtils.generateThrowableProtofor failure cases, ensuring consistent error detail control throughout the response conversion pipeline.modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/exceptions/OpenSearchExceptionProtoUtilsTests.java (3)
58-70: Good test coverage for summary mode.This test correctly verifies that when
error_trace=false, the resultingErrorCausedoes not include stack trace, suppressed exceptions, or cause information. This validates the core behavior of the new GlobalParams-driven detail control.
95-116: Thorough nested exception testing for summary mode.This test verifies that the summary mode correctly propagates through nested exceptions—both the outer exception and its cause should lack stack traces when
error_trace=false, while still preserving the cause chain structure (type, reason). Good coverage of the recursive behavior.
205-217: Good symmetry withtestInnerToProtoWithBasicException.This new test provides the counterpart to the existing basic exception test, verifying that
generateThrowableProtocorrectly omits stack traces whenerror_trace=false.modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/services/document/DocumentServiceImplTests.java (4)
44-54: Good test setup with proper cleanup, though redundant.The
@Aftermethod ensures test isolation by resettingGrpcParamsHandlerstate, which is important since it uses staticAtomicBoolean. However, both@Beforeand@Afterset the same value (true). Consider if the teardown is strictly necessary given it duplicates the setup.
81-92: Good test for server-side error trace rejection.This test correctly validates that when
grpc.detailed_errors.enabled=falseand a request haserrorTrace=true, the service rejects the request with aStatusRuntimeException. This aligns with the PR objective of failing fast when traces are requested but disabled.
94-107: Good test for allowed requests when server setting is disabled.This test verifies that requests with
errorTrace=falseproceed normally even when the server setting is disabled. The test correctly rebuilds the request with modifiedGlobalParamsand verifies thatclient.bulkis invoked.
117-121: Default request now includeserrorTrace(true).The helper method now sets
errorTrace=trueby default, which ensures existing tests exercise the stack-trace-enabled path. This is a sensible default for test coverage.modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/search/ShardStatisticsProtoUtils.java (1)
46-67: LGTM! Consistent GlobalParams propagation.The
GlobalParamsparameter is correctly added to the method signature and propagated toShardOperationFailedExceptionProtoUtils.toProtofor shard failure conversion. This maintains consistency with the broader PR pattern of threadingGlobalParamsthrough all proto conversion utilities.modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/listeners/SearchRequestActionListener.java (1)
45-64: LGTM!The
GlobalParamsis correctly propagated through both the success path (toProto) and error paths (convertToGrpcError), ensuring consistent error trace behavior across all response scenarios.modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/document/common/ShardInfoProtoUtils.java (1)
38-50: LGTM!The
GlobalParamspropagation through the shard failure conversion chain ensures that error trace settings are respected when generating the failure reason proto.modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/util/GrpcParamsHandlerTests.java (1)
18-54: Good test coverage for the critical validation paths.The tests cover the key scenarios: validation failure when server disables traces but client requests them, and successful validation when client doesn't request traces. The
isDetailedStackTraceRequestedtest verifies the basic parameter extraction.modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/GrpcParamsHandler.java (2)
30-46: LGTM! Thread-safe initialization with proper static state management.The use of
AtomicBooleanensures thread-safe access to thedetailedErrorsEnabledflag. The default value oftrueprovides a safe starting state, and theinitializemethod correctly reads from the gRPC-specific setting.
76-80: Validation logic correctly implements fail-fast behavior.The check
detailedErrorsEnabled.get() == false && globalRequestParams.getErrorTrace()precisely enforces the requirement: reject requests that ask for error traces when the server has disabled them, aligning with the HTTP-sidehttp.detailed_errors.enabledbehavior.modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/services/SearchServiceImplTests.java (1)
132-138: Good default for test helper.Setting
ErrorTrace(true)as the default increateTestSearchRequestensures existing tests exercise the primary use case, while tests needing different behavior can override viatoBuilder()as shown intestErrorTraceConfigValidationPassesWhenServerSettingIsDisabledAndRequestSkipsStackTrace.modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/listeners/BulkRequestActionListener.java (2)
30-42: LGTM! Clean threading of GlobalParams through the listener.The
GlobalParamsfield is properly stored and the constructor cleanly accepts and assigns the parameter. The Javadoc accurately describes the purpose.
51-75: Consistent error handling with GlobalParams.Both the success path (with potential conversion failure) and the failure path properly pass
paramstoGrpcErrorHandler.convertToGrpcError, ensuring consistent stack trace behavior based on request parameters.modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/DefaultShardOperationFailedExceptionProtoUtilsTests.java (3)
21-22: Appropriate use of test fixture for consistent test behavior.Using
GLOBAL_PARAMS_WITH_ERROR_TRACE_FALSEensures tests verify the non-stack-trace path consistently.
25-126: Test coverage appropriately updated for new API.All exception type test cases (DefaultShardOperationFailedException, AddBlockShardResult.Failure, IndicesShardStoresResponse.Failure, CloseIndexResponse.ShardResult.Failure, and null nodeId scenario) correctly pass
GLOBAL_PARAMS_WITH_ERROR_TRACE_FALSEto the updatedtoProtomethod.
128-135: MissingGlobalParamsparameter in null test case.This test calls
toProto(null)with a single argument, but the updated API signature istoProto(DefaultShardOperationFailedException, GlobalParams). Either this test should be updated to passGLOBAL_PARAMS_WITH_ERROR_TRACE_FALSE, or there's a separate overload for null handling that needs verification.modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/opensearchexception/OpenSearchExceptionProtoUtils.java (4)
20-21: Appropriate imports for GlobalParams support.The imports for
GlobalParamsandGrpcParamsHandlerare correctly added to support the new param-driven error detail control.
66-81: Correct propagation ofGlobalParamsthrough exception unwrapping.Both the unwrapped cause path (
generateThrowableProto(ex, params)) and the direct conversion path (innerToProto(..., params)) properly receive theGlobalParamsparameter.
96-104: Proper delegation withGlobalParamsin both exception branches.The method correctly passes
paramsto bothtoProto(for OpenSearchException) andinnerToProto(for generic Throwable), maintaining consistent error detail behavior.
121-190: Well-implemented param-driven stack trace control.The
innerToProtomethod correctly:
- Propagates
paramsto recursivegenerateThrowableProtocalls for cause (line 166) and suppressed exceptions (line 185)- Uses
GrpcParamsHandler.isDetailedStackTraceRequested(params)to conditionally include stack traces (lines 177-179)This ensures consistent error detail behavior throughout the exception hierarchy.
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/GrpcErrorHandler.java (5)
39-41: Clear constant for stack trace inclusion.The
INCLUDE_STACK_TRACESconstant correctly setsREST_EXCEPTION_SKIP_STACK_TRACEto"false", which means stack traces will be included when this parameter is used. The naming aligns with the intent.
62-136: Consistent error detail handling across all exception types.All exception branches properly use
getErrorDetailsForConfig(exception, shouldIncludeDetailedStackTrace)to determine error detail level, with appropriate special handling forOpenSearchException(delegated tohandleOpenSearchException) and null (static message).
148-159: Proper threading of stack trace flag to XContent metadata enhancement.The
handleOpenSearchExceptionmethod correctly passesshouldIncludeDetailedStackTracetoenhanceDescriptionWithXContentMetadata, ensuring consistent error detail behavior for OpenSearchExceptions.
184-190: Correct separation of request-level and server-level error detail controls.The implementation properly distinguishes between:
shouldIncludeDetailedStackTrace(request parameter) → controlsINCLUDE_STACK_TRACESvsEMPTY_PARAMSfor XContent serializationGrpcParamsHandler.isDetailedErrorsEnabled()(server setting) → passed togenerateFailureXContentThis aligns with the PR objective of providing both per-request and server-side control over error details.
215-223: Clean helper for conditional error detail selection.The
getErrorDetailsForConfigmethod clearly encapsulates the decision between full stack trace and simple message based on the request parameter. This avoids code duplication across all exception branches.modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/DefaultShardOperationFailedExceptionProtoUtils.java (4)
16-17: Appropriate import for GlobalParams.The
GlobalParamsimport is correctly added to support the param-driven error detail control.
40-60: Consistent GlobalParams propagation through all exception type branches.The
toProtomethod correctly passesparamsto all specializedinnerToProtooverloads and toparentInnerToProtofor the default case. The null case appropriately returns an empty builder without needing params.
71-118: AllinnerToProtooverloads correctly thread GlobalParams.Each specialized
innerToProtomethod forAddBlockShardResult.Failure,IndicesShardStoresResponse.Failure, andCloseIndexResponse.ShardResult.Failureproperly acceptsGlobalParamsand passes it toparentInnerToProto. Javadocs are appropriately updated.
129-142: Critical integration point: GlobalParams flows to reason generation.The
parentInnerToProtomethod correctly passesparamstoOpenSearchExceptionProtoUtils.generateThrowableProtowhen building the failure reason. This ensures the error detail level (stack traces) is controlled by the request parameters throughout the entire exception conversion chain.modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/util/GrpcErrorHandlerTests.java (4)
40-48: LGTM: Setup and teardown ensure consistent test state.Both methods initialize with
trueto ensure each test starts with a known state and resets after completion, preventing state leakage between tests.
96-118: Missing test case: server-side disabled witherror_trace=trueshould fail fast.Per the PR objectives, when
grpc.detailed_errors.enabledis false and a request includeserror_trace=true, the server should "fail fast with an error indicating traces are disabled." This test only covers the case where both server-side config and request parameter are false.Consider adding a test for the fail-fast behavior:
public void testOpenSearchExceptionConversionWhenDetailedErrorsAreDisabledButClientRequestsThem() { GrpcParamsHandler.initialize(settingsWithGivenStackTraceConfig(false)); OpenSearchException exception = new OpenSearchException("Test exception") { @Override public RestStatus status() { return RestStatus.BAD_REQUEST; } }; StatusRuntimeException result = GrpcErrorHandler.convertToGrpcError(exception, GLOBAL_PARAMS_WITH_ERROR_TRACE_TRUE); // Should fail fast with INVALID_ARGUMENT indicating traces are disabled assertEquals(Status.INVALID_ARGUMENT.getCode(), result.getStatus().getCode()); assertTrue(result.getMessage().contains("error traces in responses are disabled")); }
120-331: LGTM: Comprehensive test coverage for error_trace behavior across exception types.The paired tests (with and without error trace) for each exception type provide good coverage of the new two-argument API. The assertions verify both the gRPC status code mapping and the expected message content based on the error_trace parameter.
333-447: LGTM: Edge cases are well covered.Good coverage of edge cases including null messages, metadata extraction, XContent failures, and root cause analysis. The graceful fallback behavior when XContent extraction fails (line 422:
assertFalse(result.getMessage().contains("details="))) is particularly important for robustness.
| shardFailure.setNode(exception.nodeId()); | ||
| } | ||
| shardFailure.setStatus(exception.status().name()); | ||
| shardFailure.setReason(OpenSearchExceptionProtoUtils.generateThrowableProto(exception.getCause(), params)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# Find SnapshotShardFailure class and getCause() method
find . -type f -name "SnapshotShardFailure.java" | head -5Repository: opensearch-project/OpenSearch
Length of output: 202
🏁 Script executed:
# Search for getCause() in SnapshotShardFailure or related classes
rg -n "class SnapshotShardFailure" --type java -A 20Repository: opensearch-project/OpenSearch
Length of output: 202
🏁 Script executed:
# Search for generateThrowableProto implementation
rg -n "def generateThrowableProto|public.*generateThrowableProto" --type java -B 2 -A 10Repository: opensearch-project/OpenSearch
Length of output: 202
🏁 Script executed:
# Search for ExceptionsHelper.unwrapCause implementation
rg -n "unwrapCause" --type java -B 2 -A 10Repository: opensearch-project/OpenSearch
Length of output: 202
🌐 Web query:
OpenSearch ExceptionsHelper unwrapCause null handling
💡 Result:
Short answer: ExceptionsHelper.unwrapCause(t) returns the deepest (unwrapped) throwable it can find — and if there is no deeper cause it returns the original throwable. In other words, passing a null or a throwable with no cause yields the input (null stays null; a throwable with no cause is returned as-is). This is the behavior used in Elasticsearch / OpenSearch code that calls ExceptionsHelper.unwrapCause to find the “real” cause before mapping to status/handling. [1][2]
Sources
- Elasticsearch/OpenSearch usage and description of unwrapCause/why it’s used. [1]
- Analysis/implementation notes showing the unwrapping loop and behavior when no deeper cause is found. [2]
🌐 Web query:
OpenSearch OpenSearchExceptionProtoUtils generateThrowableProto null safety
💡 Result:
Short answer: guard against null before calling generateThrowableProto (or change the util to accept/handle null). OpenSearch utilities don’t always null-check throwables—so either check t != null and supply a default, or modify generateThrowableProto to return an empty/placeholder proto when passed null.
Suggested options (Java):
- Call-site null check
- Before calling:
if (t == null) { /* build placeholder proto or skip */ } else { OpenSearchExceptionProtoUtils.generateThrowableProto(builder, t); }
- Small defensive wrapper
- Wrap the utility so nulls are handled centrally:
public static void safeGenerateThrowableProto(Builder b, @nullable Throwable t) throws IOException {
if (t == null) {
b.setType("null").setMessage("no throwable");
return;
}
OpenSearchExceptionProtoUtils.generateThrowableProto(b, t);
}
- Patch the util (if you maintain the code)
- Edit generateThrowableProto to accept @nullable and early-return or populate a safe placeholder when t == null.
Rationale: OpenSearch exception XContent/proto helpers (see EngineException generateThrowableXContent for analogous behavior) are not guaranteed to accept null Throwables; many community reports show NPEs if exception data is missing, so defensive checks are required. [1][2]
References:
- EngineException.generateThrowableXContent (OpenSearch source reference for exception serialization helpers). [1]
- Community reports of NullPointerExceptions related to exception/aggregation serialization in OpenSearch logs/forums. [2]
If you want, tell me which OpenSearch version and the exact stack trace or code and I’ll give a concrete patch or wrapper snippet.
🌐 Web query:
SnapshotShardFailure getCause OpenSearch repository
💡 Result:
Use the Snapshot Status API (or the Java client SnapshotShardFailure model). The snapshot status response contains a failures array of SnapshotShardFailure entries; each failure exposes the human-readable failure text as the "reason" (the SnapshotShardFailure model has a reason field). Call GET /_snapshot// or GET /_snapshot/_status and inspect failures[].reason (or use the Java client SnapshotShardFailure.reason getter). [1][2]
Sources:
- OpenSearch Java client snapshot types (SnapshotShardFailure in API docs). [1]
- OpenSearch docs / error-log explaining snapshot failures and where the specific reason appears in the response. [2]
Potential NPE if exception.getCause() returns null.
The generateThrowableProto method does not safely handle null throwables. While ExceptionsHelper.unwrapCause() itself handles null gracefully, the proto generation utility requires defensive null-checking at call sites.
Add a null check before passing the cause:
- shardFailure.setReason(OpenSearchExceptionProtoUtils.generateThrowableProto(exception.getCause(), params));
+ if (exception.getCause() != null) {
+ shardFailure.setReason(OpenSearchExceptionProtoUtils.generateThrowableProto(exception.getCause(), params));
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| shardFailure.setReason(OpenSearchExceptionProtoUtils.generateThrowableProto(exception.getCause(), params)); | |
| if (exception.getCause() != null) { | |
| shardFailure.setReason(OpenSearchExceptionProtoUtils.generateThrowableProto(exception.getCause(), params)); | |
| } |
🤖 Prompt for AI Agents
In
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/SnapshotShardFailureProtoUtils.java
around line 47, the call
shardFailure.setReason(OpenSearchExceptionProtoUtils.generateThrowableProto(exception.getCause(),
params)); can NPE if exception.getCause() is null; add a defensive null check
and only call generateThrowableProto if cause != null, otherwise setReason(null)
or skip setting it, ensuring you use the unwrapped cause
(ExceptionsHelper.unwrapCause(exception)) if required and pass that to
generateThrowableProto when non-null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@karenyrx wdyt? there're a few other places to update as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason why we call .getCause()? in the rest side, they use the reason field https://github.com/opensearch-project/OpenSearch/blob/main/server/src/main/java/org/opensearch/snapshots/SnapshotShardFailure.java#L202
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good point, also on line 36 in the original diff it was
// shardFailure.setReason(exception.reason()); // TODO ErrorCause type in ShardFailure, not string
so I'll map the original exception. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@karenyrx just double checked the SnapshotShardFailure implementation. It gets created with
private SnapshotShardFailure(@Nullable String nodeId, ShardId shardId, String reason, RestStatus status) {
super(..., new IndexShardSnapshotFailedException(shardId, reason));
^^^
//internally we wrap "reason" with the IndexShardSnapshotFailedException
...
}
so the SnapshotShardFailure#reason and SnapshotShardFailure#getCause give the same error.
So, long story short SnapshotShardFailure#getCause is the error that caused the failure not the caused by one, so it should be fine if we leave it. Wdyt?
.../main/java/org/opensearch/transport/grpc/proto/response/search/SearchResponseProtoUtils.java
Outdated
Show resolved
Hide resolved
|
❌ Gradle check result for 2907384: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Sergei Ustimenko <[email protected]>
Signed-off-by: Sergei Ustimenko <[email protected]>
|
❌ Gradle check result for 8c8df96: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Sergei Ustimenko <[email protected]>
Signed-off-by: Sergei Ustimenko <[email protected]>
|
❌ Gradle check result for fac5c5e: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Sergei Ustimenko <[email protected]>
|
❌ Gradle check result for dac3694: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Sergei Ustimenko <[email protected]>
|
❌ Gradle check result for 769cdff: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
5be5c35 to
436f121
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/DefaultShardOperationFailedExceptionProtoUtilsTests.java (1)
21-135: Add test coverage forerror_trace=truescenarios.All tests exclusively use
GLOBAL_PARAMS_WITH_ERROR_TRACE_FALSE, but the PR's core feature is controlling error trace inclusion via theerror_traceparameter. The tests should verify both states to confirm the feature works correctly.Consider adding:
- Parameterized tests or additional test methods that exercise
GLOBAL_PARAMS_WITH_ERROR_TRACE_TRUE- Assertions that verify stack traces are included when
error_trace=trueand excluded whenerror_trace=false- Comparison tests demonstrating the output differs based on the GlobalParams setting
Example structure:
public void testToProtoWithErrorTraceEnabled() throws IOException { DefaultShardOperationFailedException exception = new DefaultShardOperationFailedException( "test-index", 1, new RuntimeException("Test cause") ); ShardFailure shardFailure = DefaultShardOperationFailedExceptionProtoUtils.toProto( exception, GLOBAL_PARAMS_WITH_ERROR_TRACE_TRUE ); assertNotNull(shardFailure.getReason()); // Verify stack trace is present in the reason field assertTrue("Stack trace should be included", shardFailure.getReason().hasStackTrace() || shardFailure.getReason().getStackTrace().length() > 0); } public void testToProtoWithErrorTraceDisabled() throws IOException { DefaultShardOperationFailedException exception = new DefaultShardOperationFailedException( "test-index", 1, new RuntimeException("Test cause") ); ShardFailure shardFailure = DefaultShardOperationFailedExceptionProtoUtils.toProto( exception, GLOBAL_PARAMS_WITH_ERROR_TRACE_FALSE ); assertNotNull(shardFailure.getReason()); // Verify stack trace is excluded from the reason field assertFalse("Stack trace should not be included", shardFailure.getReason().hasStackTrace()); }modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/search/SearchResponseProtoUtils.java (1)
103-103: Add GlobalParams propagation through SearchHitsProtoUtils conversion chain.
SearchResponseSectionsProtoUtils.toProtoandSearchHitsProtoUtils.toProtoboth lack theGlobalParamsparameter needed to respect serialization settings.SearchHitsProtoUtilscontains an explicit TODO acknowledging this: it currently hardcodestotalHitAsInt = falseinstead of readingRestSearchAction.TOTAL_HITS_AS_INT_PARAMfrom params. Update both utilities to accept and pass GlobalParams through the conversion chain, consistent with other response utilities in the codebase.
🧹 Nitpick comments (3)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/DefaultShardOperationFailedExceptionProtoUtilsTests.java (1)
34-42: Enhance assertions to verify error trace content.The tests now pass
GlobalParamsto control error trace inclusion, but the assertions only verify that fields are present (assertNotNull("Reason should not be null", shardFailure.getReason())). They don't verify that thereasonfield's content differs based on theerror_tracesetting.Consider strengthening the assertions to verify:
- When
error_trace=false, the reason field contains a summary without stack traces- The actual structure and content of the
reasonfield matches expectations for the givenerror_tracesettingExample for Line 34-42:
ShardFailure shardFailure = DefaultShardOperationFailedExceptionProtoUtils.toProto(exception, GLOBAL_PARAMS_WITH_ERROR_TRACE_FALSE); // Verify the result assertNotNull("ShardFailure should not be null", shardFailure); assertEquals("Shard ID should match", 1, shardFailure.getShard()); assertEquals("Index should match", "test-index", shardFailure.getIndex()); assertEquals("Status should match", RestStatus.INTERNAL_SERVER_ERROR.name(), shardFailure.getStatus()); assertNotNull("Reason should not be null", shardFailure.getReason()); +// Verify stack trace is excluded when error_trace=false +assertFalse("Stack trace should not be present", shardFailure.getReason().hasStackTrace());Also applies to: 54-63, 75-84, 96-105, 117-126, 129-135
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/util/GrpcErrorHandlerTests.java (1)
120-331: Consider reducing duplication with parameterized tests or test helpers.Each exception type has two nearly identical test methods differing only in the
GlobalParamsparameter and stack-trace assertions. This pattern repeats across ~10 exception types, resulting in significant duplication.You could refactor using JUnit's
@ParameterizedTestto reduce maintenance burden:@ParameterizedTest @MethodSource("exceptionProvider") public void testExceptionConversion(Exception exception, Status expectedStatus, String expectedMessageFragment) { StatusRuntimeException resultWithTrace = GrpcErrorHandler.convertToGrpcError(exception, GLOBAL_PARAMS_WITH_ERROR_TRACE_TRUE); assertEquals(expectedStatus.getCode(), resultWithTrace.getStatus().getCode()); assertTrue(resultWithTrace.getMessage().contains(expectedMessageFragment)); // Assert stack trace present StatusRuntimeException resultWithoutTrace = GrpcErrorHandler.convertToGrpcError(exception, GLOBAL_PARAMS_WITH_ERROR_TRACE_FALSE); assertEquals(expectedStatus.getCode(), resultWithoutTrace.getStatus().getCode()); assertTrue(resultWithoutTrace.getMessage().contains(expectedMessageFragment)); // Assert stack trace absent } private static Stream<Arguments> exceptionProvider() { return Stream.of( Arguments.of(new IllegalArgumentException("Invalid parameter"), Status.INVALID_ARGUMENT, "Invalid parameter"), Arguments.of(new IllegalStateException("Invalid state"), Status.FAILED_PRECONDITION, "Invalid state"), // ... other exception cases ); }Alternatively, extract a helper method to reduce repetition while maintaining explicit test method names. However, the current explicit structure is also acceptable if you prefer clarity over conciseness.
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/search/SearchResponseProtoUtils.java (1)
40-42: Consider null-checking params for defensive coding.While the caller likely ensures
paramsis non-null, adding a null check (e.g.,Objects.requireNonNull(params, "params must not be null")) would make the contract explicit and prevent potential NPEs if the API is misused.Also applies to: 55-59
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
CHANGELOG.md(1 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/document/bulk/BulkRequestProtoUtils.java(1 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/search/SearchRequestProtoUtils.java(1 hunks)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/search/SearchResponseProtoUtils.java(4 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/request/document/bulk/BulkRequestProtoUtilsTests.java(1 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/request/search/SearchRequestProtoUtilsTests.java(2 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/DefaultShardOperationFailedExceptionProtoUtilsTests.java(7 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/ShardOperationFailedExceptionProtoUtilsTests.java(7 hunks)modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/util/GrpcErrorHandlerTests.java(17 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/ShardOperationFailedExceptionProtoUtilsTests.java
- CHANGELOG.md
🧰 Additional context used
🧬 Code graph analysis (3)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/DefaultShardOperationFailedExceptionProtoUtilsTests.java (2)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/TestFixtures.java (1)
TestFixtures(14-24)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/DefaultShardOperationFailedExceptionProtoUtils.java (1)
DefaultShardOperationFailedExceptionProtoUtils(25-143)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/util/GrpcErrorHandlerTests.java (3)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/TestFixtures.java (1)
TestFixtures(14-24)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/GrpcParamsHandler.java (1)
GrpcParamsHandler(30-82)modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/GrpcErrorHandler.java (1)
GrpcErrorHandler(36-225)
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/request/document/bulk/BulkRequestProtoUtilsTests.java (1)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/document/bulk/BulkRequestProtoUtils.java (1)
BulkRequestProtoUtils(24-100)
🔇 Additional comments (9)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/search/SearchRequestProtoUtils.java (1)
192-195: LGTM - Narrowed global_params validation appropriately.The updated check now specifically validates
global_params.humanrather than rejecting allglobal_params, allowing other fields likeerror_traceto pass through. This aligns with the PR objective to add support for theerror_traceparameter while deferringhumansupport.modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/request/document/bulk/BulkRequestProtoUtilsTests.java (1)
145-156: LGTM - Test updated to match narrowed validation.The test correctly constructs a
GlobalParamswithhuman=trueand validates the updated exception message. This properly exercises the refined check that now targetsglobal_params.humanspecifically.modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/document/bulk/BulkRequestProtoUtils.java (1)
93-95: LGTM - Consistent with SearchRequestProtoUtils.This change mirrors the pattern in
SearchRequestProtoUtils.javaby narrowing the validation toglobal_params.human, maintaining consistency across the gRPC request utilities.modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/request/search/SearchRequestProtoUtilsTests.java (1)
412-425: LGTM - Test correctly validates the refined check.The test update mirrors the change in
BulkRequestProtoUtilsTests.java, ensuring consistent test coverage for the narrowedglobal_params.humanvalidation across both Search and Bulk request utilities.modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/util/GrpcErrorHandlerTests.java (2)
40-48: LGTM! Proper test lifecycle management.The lifecycle hooks correctly initialize the
GrpcParamsHandlerwith stack traces enabled before each test and reset to that state afterward, ensuring test isolation. Individual tests can override the configuration as needed (e.g., line 97).
50-455: Excellent test coverage of the new error-handling behavior.The tests comprehensively verify:
- OpenSearchException handling with error_trace enabled/disabled and server-side detailed errors enabled/disabled.
- Correct gRPC status code mapping for standard Java exceptions, OpenSearch exceptions, and third-party library exceptions.
- Stack trace inclusion/omission based on
GlobalParams.errorTraceand server configuration.- Edge cases: null messages, null exceptions, metadata extraction, root cause analysis, circuit breaking exceptions.
All test invocations correctly use the new two-argument
convertToGrpcError(exception, params)form, and assertions appropriately verify message content, status codes, and stack trace presence/absence.modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/search/SearchResponseProtoUtils.java (3)
36-36: LGTM! Javadoc improvements address prior feedback.The
@param paramsdocumentation is now complete and consistent across both method signatures, addressing the past review comment.Also applies to: 52-52
40-40: LGTM! GlobalParams threading is consistent.The method signature updates correctly introduce the
GlobalParamsparameter and propagate it through the conversion chain.Also applies to: 55-59
89-97: LGTM! Correct propagation to shard failure handling.Passing
paramstobuildBroadcastShardsHeaderensures shard failures respect theerror_traceparameter, which is essential for this feature.
...in/java/org/opensearch/transport/grpc/proto/request/document/bulk/BulkRequestProtoUtils.java
Outdated
Show resolved
Hide resolved
.../proto/response/exceptions/shardoperationfailedexception/SnapshotShardFailureProtoUtils.java
Outdated
Show resolved
Hide resolved
| shardFailure.setNode(exception.nodeId()); | ||
| } | ||
| shardFailure.setStatus(exception.status().name()); | ||
| shardFailure.setReason(OpenSearchExceptionProtoUtils.generateThrowableProto(exception.getCause(), params)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason why we call .getCause()? in the rest side, they use the reason field https://github.com/opensearch-project/OpenSearch/blob/main/server/src/main/java/org/opensearch/snapshots/SnapshotShardFailure.java#L202
Signed-off-by: Sergei Ustimenko <[email protected]>
…ndling-setting Signed-off-by: Sergei Ustimenko <[email protected]>
436f121 to
0769bb0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/document/bulk/BulkRequestProtoUtils.java (1)
94-98: Past review feedback addressed; TODO comment could be clarified.The
getFilterPathCount() > 0check correctly validates that the filter_path list is non-empty, addressing the previous review feedback.The TODO comment on line 94 could be more specific. The code currently supports partial
global_paramshandling—error_traceis allowed (validated downstream), whilehumanandfilter_pathare explicitly rejected. Consider updating the TODO to clarify which global_params fields remain unsupported:- // TODO support global_params parameters + // TODO support global_params.human and global_params.filter_path parameters
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
CHANGELOG.mdmodules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/document/bulk/BulkRequestProtoUtils.javamodules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/search/SearchRequestProtoUtils.javamodules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/SnapshotShardFailureProtoUtils.javamodules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/request/document/bulk/BulkRequestProtoUtilsTests.javamodules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/request/search/SearchRequestProtoUtilsTests.java
🚧 Files skipped from review as they are similar to previous changes (3)
- modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/request/document/bulk/BulkRequestProtoUtilsTests.java
- modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/search/SearchRequestProtoUtils.java
- modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/request/search/SearchRequestProtoUtilsTests.java
🧰 Additional context used
🧬 Code graph analysis (1)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/SnapshotShardFailureProtoUtils.java (1)
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/opensearchexception/OpenSearchExceptionProtoUtils.java (1)
OpenSearchExceptionProtoUtils(50-273)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
- GitHub Check: gradle-check
- GitHub Check: precommit (25, macos-15)
- GitHub Check: precommit (21, windows-2025, true)
- GitHub Check: precommit (25, ubuntu-24.04-arm)
- GitHub Check: precommit (25, windows-latest)
- GitHub Check: precommit (25, macos-15-intel)
- GitHub Check: precommit (25, ubuntu-latest)
- GitHub Check: precommit (21, ubuntu-24.04-arm)
- GitHub Check: precommit (21, ubuntu-latest)
- GitHub Check: precommit (21, windows-latest)
- GitHub Check: precommit (21, macos-15-intel)
- GitHub Check: precommit (21, macos-15)
- GitHub Check: assemble (25, ubuntu-24.04-arm)
- GitHub Check: Analyze (java)
- GitHub Check: assemble (25, windows-latest)
- GitHub Check: assemble (21, ubuntu-latest)
- GitHub Check: assemble (21, windows-latest)
- GitHub Check: assemble (25, ubuntu-latest)
- GitHub Check: assemble (21, ubuntu-24.04-arm)
- GitHub Check: detect-breaking-change
- GitHub Check: Mend Security Check
🔇 Additional comments (5)
CHANGELOG.md (1)
10-10: LGTM! Changelog entry is complete and accurate.The entry correctly captures both features introduced in this PR: the
grpc.detailed_errors.enabledsetting and the global gRPCerror_traceparameter handling. This addresses the previous review feedback about the incomplete entry.modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/SnapshotShardFailureProtoUtils.java (4)
12-17: LGTM!The new imports are necessary to support the updated method signature and the
generateThrowableProtocall. All imports are relevant and correctly added.
33-33: LGTM!The javadoc correctly documents the new
paramsparameter.
36-36: LGTM!The method signature correctly threads
GlobalParamsthrough the conversion path to enable error-detail control, aligning with the PR objectives. TheIOExceptiondeclaration is required bygenerateThrowableProto.
41-43: LGTM!The defensive null-check for
nodeIdis appropriate sinceSnapshotShardFailureaccepts a@Nullable String nodeIdparameter. This prevents potential NPEs if the node ID is absent.
.../proto/response/exceptions/shardoperationfailedexception/SnapshotShardFailureProtoUtils.java
Show resolved
Hide resolved
|
❌ Gradle check result for 0769bb0: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Description
This PR introduces:
grpc.detailed_errors.enabled(much like the similar http flag.)globalParams#errorTracerequest parameterThe
grpc.detailed_errors.enabledhas the same effect as its http counterparthttp.detailed_errors.enabled:error_trace=trueand the setting turned offerror_trace=falseerror_trace=trueSome of the test evidences are listed in this comment.
Related Issues
Resolves #19639
Check List
[ ] Public documentation issue/PR created, if applicable.Please note, that I haven't yet created the public documentation issue/PR for this setting as first I wanted to give this PR a go, get more feedback and then create the corresponding issue/PR.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.