Fix file download path encoding and host volume validation errors#257
Fix file download path encoding and host volume validation errors#257RonaldJEN wants to merge 3 commits intoalibaba:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses three independent issues across the server and Python SDK: correct handling of special characters in file download paths, clearer/safer host volume directory handling, and preserving query strings when proxying sandbox endpoint requests.
Changes:
- Create missing host bind-mount directories (or return a specific error code on failure).
- Preserve query parameters when proxying requests to sandbox endpoints.
- URL-encode download
pathfor filesystem download requests in the Python SDK.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| server/src/services/docker.py | Attempts to auto-create host volume directories and improves error reporting when creation fails. |
| server/src/services/constants.py | Adds a new error code for host path creation failures. |
| server/src/api/lifecycle.py | Ensures proxy URL includes the original request’s query string. |
| sdks/sandbox/python/src/opensandbox/sync/adapters/filesystem_adapter.py | Encodes download path into the URL query string for sync SDK downloads. |
| sdks/sandbox/python/src/opensandbox/adapters/filesystem_adapter.py | Same download path encoding adjustment for async SDK downloads. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sdks/sandbox/python/src/opensandbox/sync/adapters/filesystem_adapter.py
Outdated
Show resolved
Hide resolved
sdks/sandbox/python/src/opensandbox/sync/adapters/filesystem_adapter.py
Outdated
Show resolved
Hide resolved
|
Thanks for your contribution. Please sign the CLA first, and then resolve copilot's review comments. |
|
Hi @Pangjiping , the CLA has been signed and all Copilot review comments have been addressed. Please take a look when you have a chance. Thanks! |
- Fix file download path encoding: use quote(path, safe='/') to properly encode spaces and non-ASCII characters while preserving path separators in both sync and async filesystem adapters. - Fix host volume directory handling: auto-create missing host bind-mount directories with os.makedirs, return HTTP 500 with HOST_PATH_CREATE_FAILED error code on failure. Improve error message to use generic wording and avoid leaking raw OS error details to clients. - Fix endpoint proxy query string: preserve original query parameters when proxying requests to sandbox endpoints.
Pangjiping
left a comment
There was a problem hiding this comment.
LGTM. Please @ninan-nn review about Python sdk changes.
Summary
修复了三个相互独立的问题:
文件下载路径编码:下载含特殊字符(如空格、中文)的文件时路径解析失败,
改为 URL-encode 后作为 query string 传递。
Host volume 目录不存在时的错误处理:之前目录不存在会抛出不明确的异常,
现在自动尝试创建目录,创建失败则返回带明确 error code 的 500 响应,
便于排查。
Endpoint 代理丢失 query string:代理转发时原始请求的 query 参数未被透传,
导致下游服务收到的请求不完整,现已修复。