eric-wang-1990 opened a new pull request, #3558:
URL: https://github.com/apache/arrow-adbc/pull/3558

   ## 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-message` HTTP 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?
   
   - Add `ThriftErrorMessageHandler` as a new `DelegatingHandler` that 
intercepts HTTP error responses
   - Extract `x-thriftserver-error-message` header and include it in exception 
messages
   - Integrate handler into `DatabricksConnection` HTTP handler chain as the 
innermost handler
   - Add comprehensive unit tests covering 11 test scenarios
   - Compatible with .NET Framework 4.7.2, .NET Standard 2.0, and .NET 8.0
   
   ## Are these changes tested?
   
   Yes. Added `ThriftErrorMessageHandlerTest.cs` with 11 unit tests covering:
   - HTTP 401/403 with Thrift error messages
   - Success responses (pass through unchanged)
   - Error responses without header (pass through unchanged)
   - Empty header values (ignored)
   - Multiple HTTP status codes (400, 401, 403, 500, 503)
   - Multiple header values (joined with commas)
   
   All tests pass:
   ```
   Test Run Successful.
   Total tests: 11
        Passed: 11
    Total time: 0.6654 Seconds
   ```
   
   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:**
   ```
   An unexpected error occurred while opening the session. 'Response status 
code does not indicate success: 401 (Unauthorized).'
   ```
   
   **After:**
   ```
   An unexpected error occurred while opening the session. 'Thrift server 
error: Invalid personal access token (HTTP 401 Unauthorized)'
   ```
   
   This is a backward-compatible enhancement - if the header is not present, 
behavior is unchanged.
   
   Closes #3557


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to