Skip to content

Fix file download path encoding and host volume validation errors#257

Open
RonaldJEN wants to merge 3 commits intoalibaba:mainfrom
RonaldJEN:main
Open

Fix file download path encoding and host volume validation errors#257
RonaldJEN wants to merge 3 commits intoalibaba:mainfrom
RonaldJEN:main

Conversation

@RonaldJEN
Copy link

Summary

修复了三个相互独立的问题:

  1. 文件下载路径编码:下载含特殊字符(如空格、中文)的文件时路径解析失败,
    改为 URL-encode 后作为 query string 传递。

  2. Host volume 目录不存在时的错误处理:之前目录不存在会抛出不明确的异常,
    现在自动尝试创建目录,创建失败则返回带明确 error code 的 500 响应,
    便于排查。

  3. Endpoint 代理丢失 query string:代理转发时原始请求的 query 参数未被透传,
    导致下游服务收到的请求不完整,现已修复。

Copilot AI review requested due to automatic review settings February 27, 2026 07:36
@CLAassistant
Copy link

CLAassistant commented Feb 27, 2026

CLA assistant check
All committers have signed the CLA.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 path for 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.

@Pangjiping
Copy link
Collaborator

Pangjiping commented Feb 27, 2026

Thanks for your contribution. Please sign the CLA first, and then resolve copilot's review comments.

@RonaldJEN
Copy link
Author

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
Pangjiping previously approved these changes Mar 2, 2026
Copy link
Collaborator

@Pangjiping Pangjiping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please @ninan-nn review about Python sdk changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants