feat(csharp/src/Drivers/Databricks): capture x-thriftserver-error-message header #3558
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rationale for this change
When the Databricks ADBC C# driver encounters HTTP errors during Thrift operations (e.g., 401 Unauthorized, 403 Forbidden), the specific error message from the Databricks server is lost. The server includes detailed error information in the
x-thriftserver-error-messageHTTP response header, but currently only generic HTTP status messages reach users.This makes debugging authentication and authorization issues difficult, as users cannot distinguish between different failure causes (expired token vs. invalid token vs. insufficient permissions).
What changes are included in this PR?
ThriftErrorMessageHandleras a newDelegatingHandlerthat intercepts HTTP error responsesx-thriftserver-error-messageheader and include it in exception messagesDatabricksConnectionHTTP handler chain as the innermost handlerAre these changes tested?
Yes. Added
ThriftErrorMessageHandlerTest.cswith 11 unit tests covering:All tests pass:
Build verification also passed for all target frameworks.
Are there any user-facing changes?
Yes - users will now see detailed error messages from Databricks instead of generic HTTP status codes:
Before:
After:
This is a backward-compatible enhancement - if the header is not present, behavior is unchanged.
Closes #3557