Skip to content

Commit df5451e

Browse files
committed
Propagate x-databricks-org-id header to DBFS Volume API for SPOG routing
DBFSVolumeClient uses the SDK's ApiClient directly for /api/2.0/fs/* endpoints. These requests need the x-databricks-org-id header for SPOG routing, same as telemetry and feature flags. Add connectionContext.getCustomHeaders() to all 5 HTTP request paths in DBFSVolumeClient (4 sync via apiClient, 1 async via requestBuilder). Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore <[email protected]>
1 parent e9bff6f commit df5451e

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/main/java/com/databricks/jdbc/api/impl/volume/DBFSVolumeClient.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ CreateUploadUrlResponse getCreateUploadUrlResponse(String objectPath)
492492
CreateUploadUrlRequest request = new CreateUploadUrlRequest(objectPath);
493493
try {
494494
Request req = new Request(Request.POST, CREATE_UPLOAD_URL_PATH, apiClient.serialize(request));
495-
req.withHeaders(JSON_HTTP_HEADERS);
495+
req.withHeaders(JSON_HTTP_HEADERS).withHeaders(connectionContext.getCustomHeaders());
496496
return apiClient.execute(req, CreateUploadUrlResponse.class);
497497
} catch (IOException | DatabricksException e) {
498498
String errorMessage =
@@ -514,7 +514,7 @@ CreateDownloadUrlResponse getCreateDownloadUrlResponse(String objectPath)
514514
try {
515515
Request req =
516516
new Request(Request.POST, CREATE_DOWNLOAD_URL_PATH, apiClient.serialize(request));
517-
req.withHeaders(JSON_HTTP_HEADERS);
517+
req.withHeaders(JSON_HTTP_HEADERS).withHeaders(connectionContext.getCustomHeaders());
518518
return apiClient.execute(req, CreateDownloadUrlResponse.class);
519519
} catch (IOException | DatabricksException e) {
520520
String errorMessage =
@@ -534,7 +534,7 @@ CreateDeleteUrlResponse getCreateDeleteUrlResponse(String objectPath)
534534

535535
try {
536536
Request req = new Request(Request.POST, CREATE_DELETE_URL_PATH, apiClient.serialize(request));
537-
req.withHeaders(JSON_HTTP_HEADERS);
537+
req.withHeaders(JSON_HTTP_HEADERS).withHeaders(connectionContext.getCustomHeaders());
538538
return apiClient.execute(req, CreateDeleteUrlResponse.class);
539539
} catch (IOException | DatabricksException e) {
540540
String errorMessage =
@@ -551,7 +551,7 @@ ListResponse getListResponse(String listPath) throws DatabricksVolumeOperationEx
551551
ListRequest request = new ListRequest(listPath);
552552
try {
553553
Request req = new Request(Request.GET, LIST_PATH);
554-
req.withHeaders(JSON_HTTP_HEADERS);
554+
req.withHeaders(JSON_HTTP_HEADERS).withHeaders(connectionContext.getCustomHeaders());
555555
ApiClient.setQuery(req, request);
556556
return apiClient.execute(req, ListResponse.class);
557557
} catch (IOException | DatabricksException e) {
@@ -888,6 +888,7 @@ private CompletableFuture<CreateUploadUrlResponse> requestPresignedUrlWithRetry(
888888
Map<String, String> authHeaders = workspaceClient.config().authenticate();
889889
authHeaders.forEach(requestBuilder::addHeader);
890890
JSON_HTTP_HEADERS.forEach(requestBuilder::addHeader);
891+
connectionContext.getCustomHeaders().forEach(requestBuilder::addHeader);
891892

892893
requestBuilder.setEntity(
893894
AsyncEntityProducers.create(requestBody.getBytes(), ContentType.APPLICATION_JSON));

0 commit comments

Comments
 (0)