Skip to content

Conversation

@fdesu
Copy link
Contributor

@fdesu fdesu commented Oct 15, 2025

Description

This PR introduces:

  1. a new setting grpc.detailed_errors.enabled (much like the similar http flag.)
  2. handling of the globalParams#errorTrace request parameter

The grpc.detailed_errors.enabled has the same effect as its http counterpart http.detailed_errors.enabled:

  1. fail fast on error_trace=true and the setting turned off
  2. provide only a summary of an error in case error_trace=false
  3. provide full stack trace when error_trace=true

Some of the test evidences are listed in this comment.

Related Issues

Resolves #19639

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • [ ] 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

    • Added a server setting to enable/disable detailed gRPC error responses (defaults to enabled) and support for a client error_trace parameter to request stack traces and richer error details when allowed.
    • Server validates requests against the server setting and initializes gRPC parameter handling early.
  • Tests

    • Expanded coverage for error-trace behaviors, validation paths, and conversions with/without detailed traces.

✏️ Tip: You can customize this high-level summary in your review settings.

@fdesu fdesu requested a review from a team as a code owner October 15, 2025 09:59
@github-actions github-actions bot added enhancement Enhancement or improvement to existing feature or request Other labels Oct 15, 2025
Signed-off-by: Sergei Ustimenko <[email protected]>
@github-actions
Copy link
Contributor

❌ 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]>
@github-actions
Copy link
Contributor

✅ Gradle check result for 6392849: SUCCESS

@codecov
Copy link

codecov bot commented Oct 15, 2025

Codecov Report

❌ Patch coverage is 89.52381% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.28%. Comparing base (930ae74) to head (436f121).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
...ensearch/transport/grpc/util/GrpcErrorHandler.java 84.61% 6 Missing ⚠️
...ailedexception/SnapshotShardFailureProtoUtils.java 60.00% 0 Missing and 2 partials ⚠️
...rt/grpc/listeners/SearchRequestActionListener.java 75.00% 1 Missing ⚠️
...searchexception/OpenSearchExceptionProtoUtils.java 87.50% 1 Missing ⚠️
...oto/response/search/ShardStatisticsProtoUtils.java 0.00% 1 Missing ⚠️
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.
📢 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.

@github-actions
Copy link
Contributor

❌ 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?

@fdesu
Copy link
Contributor Author

fdesu commented Oct 21, 2025

Tests with failures:

  • org.opensearch.action.admin.indices.create.CreateIndexIT.testCreateAndDeleteIndexConcurrently
  • org.opensearch.action.admin.indices.create.CreateIndexIT.classMethod

5600 tests completed, 2 failed, 407 skipped

Looks like a failure due to a flaky test, more here: #14312

@fdesu
Copy link
Contributor Author

fdesu commented Oct 21, 2025

Hi folks, this PR is ready for review, could someone please take a look? Thanks a lot!

@karenyrx
Copy link
Contributor

Looks like a failure due to a flaky test

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)

@github-actions
Copy link
Contributor

✅ Gradle check result for bf4d92f: SUCCESS

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

❌ 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?

Copy link
Contributor

@karenyrx karenyrx left a 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?

@fdesu
Copy link
Contributor Author

fdesu commented Nov 4, 2025

Side question: Do we also eventually plan for support for REST_EXCEPTION_SKIP_STACK_TRACE as well?

@karenyrx, good question. What would be use cases here and what an implementation might look like?

Signed-off-by: Sergei Ustimenko <[email protected]>
@fdesu fdesu force-pushed the issue/19639-grpc-error-handling-setting branch from 4ba8567 to a5a64e3 Compare November 17, 2025 19:31
@github-actions
Copy link
Contributor

✅ Gradle check result for a5a64e3: SUCCESS

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2025

📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
Changelog & Plugin
CHANGELOG.md, modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/GrpcPlugin.java
Documents feature and exposes SETTING_GRPC_DETAILED_ERRORS_ENABLED; initializes GrpcParamsHandler during aux transport setup.
Transport Setting
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/Netty4GrpcServerTransport.java
Adds node-scoped boolean SETTING_GRPC_DETAILED_ERRORS_ENABLED (default true).
Grpc Params Handler
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/GrpcParamsHandler.java
New utility: initialize from Settings, inspect request GlobalParams.error_trace, validate request vs server setting, and expose query helpers.
Services
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/services/... (DocumentServiceImpl.java, SearchServiceImpl.java)
Validate request GlobalParams via GrpcParamsHandler; pass GlobalParams to listeners; use params when converting errors.
Listeners
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/listeners/... (BulkRequestActionListener.java, SearchRequestActionListener.java)
Constructors now accept GlobalParams; response conversions call toProto(..., params); error conversion calls include params.
Error Handling
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/util/GrpcErrorHandler.java
New overload accepting GlobalParams; determines inclusion of detailed stack traces via GrpcParamsHandler and conditions XContent/description generation accordingly.
Proto utils — Exceptions & Failures
modules/transport-grpc/src/main/java/.../proto/response/exceptions/... (e.g., OpenSearchExceptionProtoUtils.java, ShardOperationFailedExceptionProtoUtils.java, DefaultShardOperationFailedExceptionProtoUtils.java, ReplicationResponseShardInfoFailureProtoUtils.java, ShardSearchFailureProtoUtils.java, SnapshotShardFailureProtoUtils.java)
Thread GlobalParams through exception-to-proto conversions; use params to decide inclusion of causes, suppressed exceptions, and stack traces.
Proto utils — Responses & Shard Stats
modules/transport-grpc/src/main/java/.../proto/response/... (e.g., BulkResponseProtoUtils.java, BulkItemResponseProtoUtils.java, DocWriteResponseProtoUtils.java, ShardInfoProtoUtils.java, SearchResponseProtoUtils.java, ProtoActionsProtoUtils.java, ShardStatisticsProtoUtils.java)
Propagate GlobalParams into response conversion and shard statistics to ensure error serialization respects request params.
Request parsing guards
modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/... (BulkRequestProtoUtils.java, SearchRequestProtoUtils.java)
Narrow unsupported global_params checks to global_params.human or filter_path; update thrown messages.
Plugin tests & Fixtures
modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/TestFixtures.java, modules/transport-grpc/src/test/java/.../GrpcPluginTests.java
Adds test fixtures for GlobalParams and settings helper; updates expected settings count.
Unit tests updated/added
modules/transport-grpc/src/test/java/... (many tests: listeners, proto utils, services, GrpcErrorHandlerTests, GrpcParamsHandlerTests, etc.)
Tests updated to pass GlobalParams, initialize/reset GrpcParamsHandler, assert summary vs detailed error outputs, and add validation tests for request vs server config.
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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • msfroh
  • peternied
  • andrross
  • reta

Poem

🐇 I hopped through params, gentle and spry,
I learned when traces may live or must die.
I threaded GlobalParams—soft as a sigh,
Errors now whisper or loudly reply.
I celebrate with a carrot and a sky-high hop 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.16% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly and specifically summarizes the main changes: adding a new gRPC setting for detailed errors and handling the error_trace parameter.
Description check ✅ Passed Description adequately covers the PR objectives, lists related issues, includes functionality testing, and notes API specification companion PR creation.
Linked Issues check ✅ Passed Code changes fully implement requirements from issue #19639: new grpc.detailed_errors.enabled setting, error_trace parameter handling, and behavior matching HTTP semantics.
Out of Scope Changes check ✅ Passed All changes are scoped to gRPC error handling and parameter propagation; no unrelated modifications detected beyond the stated objectives.
✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@fdesu fdesu force-pushed the issue/19639-grpc-error-handling-setting branch from 5ceb0ee to 2907384 Compare December 4, 2025 09:09
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 explicit assertTrue check 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 params argument is properly propagated to BulkItemResponseProtoUtils.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_FALSE for the updated toProto() signature.

Consider adding a test case with GLOBAL_PARAMS_WITH_ERROR_TRACE_TRUE for the testToProtoWithFailures scenario 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 using TestFixtures.GLOBAL_PARAMS_WITH_ERROR_TRACE_FALSE (which is equivalent since errorTrace defaults to false).

+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 for params parameter.

The constructor stores params without validation, but both onResponse and onFailure paths use it. If a caller passes null, this would cause an NPE when SearchResponseProtoUtils.toProto or GrpcErrorHandler.convertToGrpcError is 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 @param documentation for params.

The Javadoc for the private toProto method is missing the @param params entry 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. Since validateStackTraceDetailsConfiguration doesn'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 @After reset when @Before already initializes.

Both @Before and @After call GrpcParamsHandler.initialize(settingsWithGivenStackTraceConfig(true)). Since @Before runs before each test, the @After reset 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 @After method can be removed since @Before already handles initialization.


117-130: Misleading variable name in passing test case.

The variable serviceThatFailsToProvideErrorInfo is 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 for params parameter.

The @param params documentation 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 details
modules/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

📥 Commits

Reviewing files that changed from the base of the PR and between b7f013f and 2907384.

📒 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_FALSE from TestFixtures provides a clean way to supply the required GlobalParams parameter across all test cases.


52-55: Consistent update to the new method signature.

All toProto calls are correctly updated to pass GLOBAL_PARAMS_WITH_ERROR_TRACE_FALSE, aligning with the production code's new signature that requires GlobalParams for 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-argument toProto overload 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 GlobalParams parameter type.


35-39: Proper Javadoc and signature update for GlobalParams threading.

The method signature correctly includes the GlobalParams parameter with appropriate documentation. This enables error trace control to propagate through the proto conversion chain.


61-61: Correct propagation of GlobalParams to downstream conversion.

GlobalParams is properly passed to ShardInfoProtoUtils.toProto, which (per the relevant code snippet) uses it when generating error causes via OpenSearchExceptionProtoUtils.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_ENABLED setting follows the established pattern for gRPC transport settings. The Javadoc clearly explains the interaction between this server-side setting and the per-request error_trace parameter, which matches the PR's stated objectives for parity with HTTP behavior. Verify that this setting is consumed in GrpcParamsHandler or 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.enabled setting.


291-292: Setting correctly exposed via getSettings().

The new SETTING_GRPC_DETAILED_ERRORS_ENABLED is 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_FALSE to 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 params argument is properly passed to generateThrowableProto(), ensuring stack trace inclusion respects the error_trace setting 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 params argument is properly passed to generateThrowableProto(), 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 use GLOBAL_PARAMS_WITH_ERROR_TRACE_FALSE.

Consider adding a test case with GLOBAL_PARAMS_WITH_ERROR_TRACE_TRUE to verify behavior when error traces are enabled, particularly for scenarios involving shard failures where the GlobalParams would 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:

  1. Validates stack trace configuration early (fail-fast pattern)
  2. Propagates GlobalParams to both the listener and error handler
  3. 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 GlobalParams parameter 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 onFailure triggers onError with a StatusRuntimeException. The refactoring to use the class-level responseObserver is cleaner.

modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/search/ProtoActionsProtoUtils.java (1)

43-54: LGTM - Clean GlobalParams propagation.

The GlobalParams parameter is correctly added to the method signature and propagated to ShardStatisticsProtoUtils.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 GlobalParams is correctly propagated through the conversion chain to ProtoActionsProtoUtils.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:

  1. Validates stack trace configuration early via GrpcParamsHandler.validateStackTraceDetailsConfiguration
  2. Propagates GlobalParams to the listener and error handler
  3. Handles both RuntimeException and IOException appropriately

This aligns well with DocumentServiceImpl and the broader GlobalParams propagation 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() and nodeId() (lines 38-45) is a good defensive practice. The method signature correctly propagates GlobalParams to 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 GlobalParams parameter is properly passed to both DocWriteResponseProtoUtils.toProto for success cases and OpenSearchExceptionProtoUtils.generateThrowableProto for 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 resulting ErrorCause does 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 with testInnerToProtoWithBasicException.

This new test provides the counterpart to the existing basic exception test, verifying that generateThrowableProto correctly omits stack traces when error_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 @After method ensures test isolation by resetting GrpcParamsHandler state, which is important since it uses static AtomicBoolean. However, both @Before and @After set 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=false and a request has errorTrace=true, the service rejects the request with a StatusRuntimeException. 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=false proceed normally even when the server setting is disabled. The test correctly rebuilds the request with modified GlobalParams and verifies that client.bulk is invoked.


117-121: Default request now includes errorTrace(true).

The helper method now sets errorTrace=true by 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 GlobalParams parameter is correctly added to the method signature and propagated to ShardOperationFailedExceptionProtoUtils.toProto for shard failure conversion. This maintains consistency with the broader PR pattern of threading GlobalParams through all proto conversion utilities.

modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/listeners/SearchRequestActionListener.java (1)

45-64: LGTM!

The GlobalParams is 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 GlobalParams propagation 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 isDetailedStackTraceRequested test 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 AtomicBoolean ensures thread-safe access to the detailedErrorsEnabled flag. The default value of true provides a safe starting state, and the initialize method 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-side http.detailed_errors.enabled behavior.

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 in createTestSearchRequest ensures existing tests exercise the primary use case, while tests needing different behavior can override via toBuilder() as shown in testErrorTraceConfigValidationPassesWhenServerSettingIsDisabledAndRequestSkipsStackTrace.

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 GlobalParams field 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 params to GrpcErrorHandler.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_FALSE ensures 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_FALSE to the updated toProto method.


128-135: Missing GlobalParams parameter in null test case.

This test calls toProto(null) with a single argument, but the updated API signature is toProto(DefaultShardOperationFailedException, GlobalParams). Either this test should be updated to pass GLOBAL_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 GlobalParams and GrpcParamsHandler are correctly added to support the new param-driven error detail control.


66-81: Correct propagation of GlobalParams through exception unwrapping.

Both the unwrapped cause path (generateThrowableProto(ex, params)) and the direct conversion path (innerToProto(..., params)) properly receive the GlobalParams parameter.


96-104: Proper delegation with GlobalParams in both exception branches.

The method correctly passes params to both toProto (for OpenSearchException) and innerToProto (for generic Throwable), maintaining consistent error detail behavior.


121-190: Well-implemented param-driven stack trace control.

The innerToProto method correctly:

  1. Propagates params to recursive generateThrowableProto calls for cause (line 166) and suppressed exceptions (line 185)
  2. 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_TRACES constant correctly sets REST_EXCEPTION_SKIP_STACK_TRACE to "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 for OpenSearchException (delegated to handleOpenSearchException) and null (static message).


148-159: Proper threading of stack trace flag to XContent metadata enhancement.

The handleOpenSearchException method correctly passes shouldIncludeDetailedStackTrace to enhanceDescriptionWithXContentMetadata, 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:

  1. shouldIncludeDetailedStackTrace (request parameter) → controls INCLUDE_STACK_TRACES vs EMPTY_PARAMS for XContent serialization
  2. GrpcParamsHandler.isDetailedErrorsEnabled() (server setting) → passed to generateFailureXContent

This 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 getErrorDetailsForConfig method 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 GlobalParams import is correctly added to support the param-driven error detail control.


40-60: Consistent GlobalParams propagation through all exception type branches.

The toProto method correctly passes params to all specialized innerToProto overloads and to parentInnerToProto for the default case. The null case appropriately returns an empty builder without needing params.


71-118: All innerToProto overloads correctly thread GlobalParams.

Each specialized innerToProto method for AddBlockShardResult.Failure, IndicesShardStoresResponse.Failure, and CloseIndexResponse.ShardResult.Failure properly accepts GlobalParams and passes it to parentInnerToProto. Javadocs are appropriately updated.


129-142: Critical integration point: GlobalParams flows to reason generation.

The parentInnerToProto method correctly passes params to OpenSearchExceptionProtoUtils.generateThrowableProto when 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 true to 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 with error_trace=true should fail fast.

Per the PR objectives, when grpc.detailed_errors.enabled is false and a request includes error_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));
Copy link
Contributor

@coderabbitai coderabbitai bot Dec 4, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Find SnapshotShardFailure class and getCause() method
find . -type f -name "SnapshotShardFailure.java" | head -5

Repository: opensearch-project/OpenSearch

Length of output: 202


🏁 Script executed:

# Search for getCause() in SnapshotShardFailure or related classes
rg -n "class SnapshotShardFailure" --type java -A 20

Repository: opensearch-project/OpenSearch

Length of output: 202


🏁 Script executed:

# Search for generateThrowableProto implementation
rg -n "def generateThrowableProto|public.*generateThrowableProto" --type java -B 2 -A 10

Repository: opensearch-project/OpenSearch

Length of output: 202


🏁 Script executed:

# Search for ExceptionsHelper.unwrapCause implementation
rg -n "unwrapCause" --type java -B 2 -A 10

Repository: 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):

  1. Call-site null check
  • Before calling:
    if (t == null) { /* build placeholder proto or skip */ } else { OpenSearchExceptionProtoUtils.generateThrowableProto(builder, t); }
  1. 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);
    }
  1. 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.

Suggested change
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.

Copy link
Contributor Author

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

Copy link
Contributor

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!

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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!

Copy link
Contributor Author

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?

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

❌ 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?

@fdesu fdesu marked this pull request as draft December 5, 2025 11:56
Signed-off-by: Sergei Ustimenko <[email protected]>
Signed-off-by: Sergei Ustimenko <[email protected]>
@github-actions
Copy link
Contributor

❌ 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?

@github-actions
Copy link
Contributor

❌ 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?

@github-actions
Copy link
Contributor

❌ 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]>
@github-actions
Copy link
Contributor

❌ 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?

@fdesu fdesu force-pushed the issue/19639-grpc-error-handling-setting branch from 5be5c35 to 436f121 Compare December 17, 2025 20:35
@github-actions
Copy link
Contributor

✅ Gradle check result for 436f121: SUCCESS

@fdesu fdesu marked this pull request as ready for review December 17, 2025 22:02
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 for error_trace=true scenarios.

All tests exclusively use GLOBAL_PARAMS_WITH_ERROR_TRACE_FALSE, but the PR's core feature is controlling error trace inclusion via the error_trace parameter. 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=true and excluded when error_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.toProto and SearchHitsProtoUtils.toProto both lack the GlobalParams parameter needed to respect serialization settings. SearchHitsProtoUtils contains an explicit TODO acknowledging this: it currently hardcodes totalHitAsInt = false instead of reading RestSearchAction.TOTAL_HITS_AS_INT_PARAM from 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 GlobalParams to 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 the reason field's content differs based on the error_trace setting.

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 reason field matches expectations for the given error_trace setting

Example 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 GlobalParams parameter and stack-trace assertions. This pattern repeats across ~10 exception types, resulting in significant duplication.

You could refactor using JUnit's @ParameterizedTest to 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 params is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2907384 and 436f121.

📒 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.human rather than rejecting all global_params, allowing other fields like error_trace to pass through. This aligns with the PR objective to add support for the error_trace parameter while deferring human support.

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 GlobalParams with human=true and validates the updated exception message. This properly exercises the refined check that now targets global_params.human specifically.

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.java by narrowing the validation to global_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 narrowed global_params.human validation 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 GrpcParamsHandler with 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.errorTrace and 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 params documentation 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 GlobalParams parameter and propagate it through the conversion chain.

Also applies to: 55-59


89-97: LGTM! Correct propagation to shard failure handling.

Passing params to buildBroadcastShardsHeader ensures shard failures respect the error_trace parameter, which is essential for this feature.

shardFailure.setNode(exception.nodeId());
}
shardFailure.setStatus(exception.status().name());
shardFailure.setReason(OpenSearchExceptionProtoUtils.generateThrowableProto(exception.getCause(), params));
Copy link
Contributor

Choose a reason for hiding this comment

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

Signed-off-by: Sergei Ustimenko <[email protected]>
@fdesu fdesu force-pushed the issue/19639-grpc-error-handling-setting branch from 436f121 to 0769bb0 Compare December 30, 2025 09:44
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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() > 0 check 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_params handling—error_trace is allowed (validated downstream), while human and filter_path are 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

📥 Commits

Reviewing files that changed from the base of the PR and between 436f121 and 0769bb0.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/document/bulk/BulkRequestProtoUtils.java
  • modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/search/SearchRequestProtoUtils.java
  • modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/response/exceptions/shardoperationfailedexception/SnapshotShardFailureProtoUtils.java
  • modules/transport-grpc/src/test/java/org/opensearch/transport/grpc/proto/request/document/bulk/BulkRequestProtoUtilsTests.java
  • modules/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.enabled setting and the global gRPC error_trace parameter 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 generateThrowableProto call. All imports are relevant and correctly added.


33-33: LGTM!

The javadoc correctly documents the new params parameter.


36-36: LGTM!

The method signature correctly threads GlobalParams through the conversion path to enable error-detail control, aligning with the PR objectives. The IOException declaration is required by generateThrowableProto.


41-43: LGTM!

The defensive null-check for nodeId is appropriate since SnapshotShardFailure accepts a @Nullable String nodeId parameter. This prevents potential NPEs if the node ID is absent.

@github-actions
Copy link
Contributor

❌ 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?

@fdesu fdesu marked this pull request as draft January 5, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhancement or improvement to existing feature or request Other

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request][gRPC] Add separate error handling setting for gRPC

2 participants