opensearch-project / opensearch-project/sql-jdbc
[Bug] InternalServerErrorException swallows error details from getMessage(), hiding OpenSearch server errors from JDBC clients
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 28
- Forks
- 39
- PR merge metrics
- No merged PRs in 30d
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;
}
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.
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.
Assessment
- Tech stack
- java
- Domain
- database
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100