[Bug] InternalServerErrorException swallows error details from getMessage(), hiding OpenSearch server errors from JDBC clients
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Start with InternalServerErrorException.java in org.opensearch.jdbc.protocol.exceptions and inspect how its constructor initializes the server error fields and parent SQLNonTransientException. Check similarly structured exception classes for the same behavior. Done means JDBC clients receive the OpenSearch reason, type, and details through getMessage() instead of null.
Written by the indexing model from the issue text.
Description
Describe the bug
When the OpenSearch server returns an HTTP 500 error (such as Internal Server Error / all shards failed) via the SQL API, the opensearch-sql-jdbc driver fails to expose the error reason and details through standard JDBC Exception handling.
Specifically, the InternalServerErrorException class (and potentially other exception classes in org.opensearch.jdbc.protocol.exceptions) does not pass a formatted error message to its parent SQLNonTransientException via super(message), nor does it override getMessage().
As a result, standard JDBC clients (like logstash-input-jdbc) that rely on Exception.getMessage() will simply output null. For example, Logstash logs:
Java::OrgOpensearchJdbcProtocolExceptions::InternalServerErrorException: null
This completely swallows the actual OpenSearch server error, making it incredibly difficult for users to debug SQL failures through the JDBC driver.
To Reproduce
Steps to reproduce the behavior:
- Connect a JDBC client (e.g., Logstash
logstash-input-jdbcor DBeaver) to OpenSearch using theopensearch-sql-jdbcdriver. - Execute a query that intentionally triggers a server-side runtime error (for example, triggering
all shards failedby passing an invalidCASTor date format during a cursor-based fetch). - Check the client logs. The actual JSON error response from OpenSearch containing the
reasonanddetailsis swallowed, and the client only receives anullmessage.
Expected behavior
The exception should expose the reason and details when getMessage() is called, so that JDBC clients can log the true root cause.
Proposed Fix
Update InternalServerErrorException.java (and similarly structured exceptions) to either override getMessage() or pass a formatted message to the super constructor:
public InternalServerErrorException(String reason, String type, String details) {
// Pass the error message to the parent Exception class
super(String.format("Reason: %s, Type: %s, Details: %s", reason, type, details));
this.reason = reason;
this.type = type;
this.details = details;
}
- Dominant language
- Java
- Stars
- 28
- Forks
- 39
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from opensearch-project/sql-jdbc
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
opensearch-project/sql-jdbc#14 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
opensearch-project/sql-jdbc#143 · 1 comment ·
-
Mend: dependency security vulnerability
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
opensearch-project/sql-jdbc#140 ·
-
bug good first issue
Difficulty 4/5 3-5 days Newbie friendliness 42/100
opensearch-project/sql-jdbc#128 · 2 comments ·
-
catch-all acknowledged infrastructure
Difficulty 4/5 3-5 days Newbie friendliness 25/100
opensearch-project/sql-jdbc#127 · 1 comment ·
All issues in opensearch-project/sql-jdbc
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100