[ISSUE] Workspace Client files.download fails in Databricks App
Maintainer thường phản hồi trong vòng 1 ngày
@deepan-crypto đang làm issue này rồi.
Từ ngày 3/10/2026.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- api, authentication
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện WorkspaceClient.files.download với x-forwarded-access-token và so sánh với yêu cầu GET trực tiếp được mô tả trong issue. Kiểm tra databricks/sdk/mixins/files.py, databricks/sdk/service/files.py, databricks/sdk/core.py và databricks/sdk/_base_client.py theo đường dẫn traceback. Được xem là hoàn tất khi việc tải xuống của client hoạt động với token của ứng dụng đã triển khai và có coverage cho hành vi của phạm vi quyền.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
When using the files.download method in the Workspace Client, this works locally with an injected user access token but failing with the downscoped user-authorisation x-forwarded-access-token.
When calling the GET API directly at <host>/api/2.0/fs/files this works fine for both local and deployed Databricks App.
Reproduction
@router.get("/get_image/{image_path:path}")
async def get_databricks_image(
request: Request,
image_path: str):
from databricks.sdk.core import Config
from Databricks.sdk import WorkspaceClient
import jwt
import databricks
access_token = request.headers.get("x-forwarded-access-token")
try:
cfg = Config(host=<HOST>,
token=access_token,
auth_type="pat",
)
w = WorkspaceClient(config=cfg)
logger.info(f"Fetching image from Databricks: {image_path}")
resp: DownloadResponse = w.files.download(image_path)
# Get binary image content
image_bytes = resp.contents.read()
# Convert binary image to base64 string
image_base64 = base64.b64encode(image_bytes).decode('utf-8')
except Exception as e:
logger.error(f"Full traceback:\n{traceback.format_exc()}")
return JSONResponse(
status_code=500,
content={"error": str(e)},
)
return JSONResponse(content={"image_data": image_base64, "path": image_path})
Expected behavior
This works when testing locally with a Workspace level Admin account by using Databricks auth login and then adding a middleware in FastAPI to inject the x-forwarded-access-token by reading the access_token from the local ~/.databricks/token-cache.json file.
When deployed to Databricks App, this errors out:
databricks.sdk.errors.platform.PermissionDenied: Provided OAuth token does not have required scopes
Is it a regression?
Not a regression AFAIK
Debug Logs
2026-02-18 04:26:46,783 [ERROR] Full traceback: Traceback (most recent call last): File "/app/python/source_code/routes/v1/image_search.py", line 271, in get_databricks_image resp: DownloadResponse = w.files.download(image_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/python/source_code/.venv/lib/python3.11/site-packages/databricks/sdk/mixins/files.py", line 800, in download return super().download(file_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/python/source_code/.venv/lib/python3.11/site-packages/databricks/sdk/service/files.py", line 881, in download res = self._api.do( ^^^^^^^^^^^^^ File "/app/python/source_code/.venv/lib/python3.11/site-packages/databricks/sdk/core.py", line 86, in do return self._api_client.do( ^^^^^^^^^^^^^^^^^^^^ File "/app/python/source_code/.venv/lib/python3.11/site-packages/databricks/sdk/_base_client.py", line 199, in do response = call( ^^^^^ File "/app/python/source_code/.venv/lib/python3.11/site-packages/databricks/sdk/retries.py", line 59, in wrapper raise err File "/app/python/source_code/.venv/lib/python3.11/site-packages/databricks/sdk/retries.py", line 38, in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/app/python/source_code/.venv/lib/python3.11/site-packages/databricks/sdk/_base_client.py", line 301, in _perform raise error from None
Other Information
Databricks SDK version: 0.83.0
Additional context
Pair programming session done with Databricks engineer Naim on 13th of February 2026 to diagnose issue. Implementation changed to raw HTTP request instead of workspace client.
- Ngôn ngữ chính
- Python
- Star
- 577
- Fork
- 229
- Merge trung bình
- 40 phút
- Pull request đã merge (30 ngày)
- 12
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của databricks/databricks-sdk-py
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 62/100
databricks/databricks-sdk-py#1602 · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[ISSUE] Docs state serving endpoints support at most ten served entities; actual limit is 15Có thể đã có người làm @divya0709 đã nhận 95 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
databricks/databricks-sdk-py#1496 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
databricks/databricks-sdk-py#1495 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[ISSUE] `get_api_error` fails with `TypeError: object of type '_io.BufferedReader' has no len()¨`Có thể đã có người làm @mittalpk đã nhận 111 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
databricks/databricks-sdk-py#1489 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
databricks/databricks-sdk-py#1451 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của databricks/databricks-sdk-py
Issue tương tự
-
Unknown stop ID in slow zone data crashes post formatting and skips the rest of that day's postsĐang mởbackend bug tm-new-volunteer
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
transitmatters/mbta-slow-zone-bot#81 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
spacetelescope/rdmt-spire#49 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
AI bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
AUTO-MAS-Project/AUTO-MAS#1960 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
btclib-org/btclib-wallet#872 ·
Maintainer thường phản hồi trong vòng 1 ngày