Merged
fix(py-sdk): use http replace https, add whl build #101
fly_1997Add on Aug 28
fix(py-sdk): use http replace https, add whl build #101
Merged
fly_1997Add on Aug 28
fly_1997
fly_1997Collaborators
Aug 28

当前PR是否有AI参与:

[x] 否

[ ] 是
__1. AI Agent 平台:
__2. AI 模型:
__3. Prompt上下文 :

参考:openEuler社区《生成式AI工具使用与开源贡献政策》

PR功能描述 / 为什么需要这个合入**:

该PR关联的issue

(格式为fixes #<issue号>, 或者resolves #<issue号>): fixes #

希望检视人员了解:

likedislike
Pull Request has been successfully merged by openeuler-ci-bot.
(Thank you for fly_1997's contribution.)
fly_1997fly_1997Collaborators
Aug 28 Created pull request, commit dfdc3860
atomgit-bot
atomgit-bot
Aug 28 Comments:

变更摘要

本 PR 主要针对 py-sdk 做两方面的修复与增强:一是将 connection_config.py 中默认 API 地址与沙箱地址的协议由 https 改为 http;二是在 dockerfile_parser.py 中注释掉模板解析时对用户(user)与工作目录(workdir)的默认设置逻辑;同时新增 build-wheel.sh 脚本用于将 py-sdk 构建为 .whl 产物。

主要改动

  • API 默认协议改为 http:在 ConnectionConfig 中,api_url 的默认值由 https://api.<domain> 改为 http://api.<domain>,沙箱地址的拼接逻辑也统一改用 http 协议,不再区分 debug 模式。
  • 注释 Dockerfile 解析中的 user/workdir 设置:在 parse_dockerfile 中注释掉将用户与工作目录重置为 Docker 默认值(root、/)以及未变更时设置 E2B 默认值(user、/home/user)的代码,即不再强制改写镜像的用户与工作目录。
  • 新增 wheel 构建脚本:新增 py-sdk/scripts/build-wheel.sh,基于 pyproject.toml 的 poetry-core 构建后端,自动安装 python-build 工具、清理旧构建产物,并通过 python3 -m build --wheel 在 dist/ 目录输出 .whl 文件。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Aug 28 Comments:

代码审查

I have completed a full review of all three changed files. Final summary:

变更文件审查结果

1. py-sdk/e2b/connection_config.py — 发现 3 个问题

  • P1(line 117):生产默认 api_url 从 https://api.<domain> 降级为明文 http://api.<domain>,API Key 将明文传输,且与未修改的 VolumeConnectionConfig(仍为 https)契约分歧。
  • P2(line 117):现有单测 tests/test_connection_config.py:8 断言 "https://api.e2b.app",改动后必然失败,本 diff 未同步更新测试。
  • P2(line 143):{'http' if self.debug else 'http'} 三元表达式恒真失效(死代码),且生产 sandbox 连接降级为明文 http,envd access token 明文传输。

2. py-sdk/e2b/template/dockerfile_parser.py — 发现 2 个问题

  • P2(lines 108-109):注释掉 E2B 默认 user/workdir 设置,静默改变模板构建契约(不再默认 user="user"、workdir="/home/user"),且与 PR 标题所述内容无关,疑似调试遗留。
  • P3(lines 138-141):留下只写不读的死变量 user_changed/workdir_changed 与误导性注释。

3. py-sdk/scripts/build-wheel.sh — 发现 1 个问题

  • P3(line 13):pip install build 直接污染全局 Python 环境,且在 PEP 668(externally-managed-environment)发行版上会导致构建失败。

总体风险判断

共报告 6 个问题:P1 × 1、P2 × 3、P3 × 2。

本 PR 核心风险集中在 connection_config.py 的 https→http 降级:它将 SDK 生产默认流量(含 API Key、envd access token)从加密改为明文,属于安全回退,同时确定性破坏现有单测;dockerfile_parser.py 的注释改动与 PR 主题无关,疑似调试遗留,静默改变模板构建行为。build-wheel.sh 问题轻微。整体风险为中高,建议合入前优先确认 http 降级意图并恢复 https 默认值或同步更新测试。

类型 数量
🔴 阻塞 1
🟡 建议 2

⛔ 需要修改

likedislike
Incorrect?
openeuler-ci-botopeneuler-ci-botCollaborators
Aug 28 Set weibaohui,yangzhao_kl,jimmieme,duguhaotian,wonleing,zmr_2020,gaodaweiky,lu-wei-army,zhaoyifan28 as approver
openeuler-ci-botopeneuler-ci-botCollaborators
Aug 28 Added label: sig/sig-CloudNative
openeuler-ci-bot
openeuler-ci-botCollaborators
Aug 28 Comments:

Welcome To openEuler Community

Hey @fly_1997 , thanks for your contribution to the community.

Bot Usage Manual

I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands. You can self-configure the PR merge rules for this repository. For more details, please refer to Here.

Contact Guide

If you have any questions, please contact the SIG: sig-CloudNative ,
and any of the maintainers: @duguhaotian, @gaodaweiky, @jimmieme, @lu-wei-army, @weibaohui, @wonleing, @yangzhao_kl, @zhaoyifan28, @zmr_2020 ,
and any of the committers: @feijianqiang, @zhourenjianz .

likedislike
openeuler-ci-botopeneuler-ci-botCollaborators
Aug 28 Added label: openeuler-cla/yes
openeuler-ci-bot
openeuler-ci-botCollaborators
Aug 28 Comments:

CLA Signature Pass

fly_1997, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
openeuler-ci-botopeneuler-ci-botCollaborators
Aug 28 Added label: ci_processing
openeuler-ci-bot
openeuler-ci-botCollaborators
Aug 28 Comments:

门禁正在运行, 您可以通过以下链接查看实时门禁检查结果.
若您对门禁结果含义不清晰或者遇到问题不知如何解决,可参考门禁指导手册
门禁入口及编码规范检查: multiarch/openeuler/trigger/KASandbox/247/console

likedislike
atomgit-bot
atomgit-botAug 28Start code review1
py-sdk/e2b/connection_config.py
@@ -115,3 +115,3 @@
115115 api_url
116116 or ConnectionConfig._api_url()
117- or ("http://localhost:3000" if self.debug else f"https://api.{self.domain}")
117+ or ("http://localhost:3000" if self.debug else f"http://api.{self.domain}")
atomgit-bot
atomgit-botAug 28Comments:

🟡 Medium Priority

变更行:connection_config.py:117 把默认 api_url 从 https://api.e2b.app 改为 http://api.e2b.app。

受影响行为/契约:未修改的测试 tests/test_connection_config.py:8 断言 config.api_url == "https://api.e2b.app"(E2B_DOMAIN=""、debug 为 false)。改动后默认值变为 http://api.e2b.app,断言必然失败。

失败模式:本 diff 未同步更新测试,CI 中 test_api_url_defaults_correctly 确定性失败,属于本次改动引入的回归(改动行与未修改测试契约不一致)。

建议:恢复 https 默认值;若坚持 http 默认,则同步修改 tests/test_connection_config.py 的 test_api_url_defaults_correctly 断言,保证测试与新契约一致。

likedislike
Incorrect?
atomgit-bot
atomgit-botAug 28Start code review1
py-sdk/e2b/connection_config.py
@@ -115,3 +115,3 @@
115115 api_url
116116 or ConnectionConfig._api_url()
117- or ("http://localhost:3000" if self.debug else f"https://api.{self.domain}")
117+ or ("http://localhost:3000" if self.debug else f"http://api.{self.domain}")
atomgit-bot
atomgit-botAug 28Comments:

🟠 High Priority

变更行:connection_config.py:117 将非 debug 分支的默认 API 地址从 f"https://api.{self.domain}" 改为 f"http://api.{self.domain}"。

受影响行为/契约:ConnectionConfig 在未显式传入 api_url、未设置 E2B_API_URL 时,生产(非 debug)默认值变为明文 http://api.<domain>。该 api_url 经 get_api_params() 传入 API 客户端(如 template_sync/main.py 中 ConnectionConfig(**opts) + get_api_client(config, require_[REDACTED] api_key` 的请求头会直接发送到该地址。

失败模式:默认配置下,E2B API Key 将以明文 HTTP 方式在网络上传输,可被中间人窃取;若 api.e2b.app 只支持 HTTPS,所有默认 API 调用将直接失败,构成生产功能回归。同时该改动与未修改的姊妹类 VolumeConnectionConfig(其默认仍为 https://api.e2b.app)产生契约分歧。

建议:将非 debug 分支恢复为 f"https://api.{self.domain}";若需 http 则改为通过 E2B_API_URL 环境变量或 api_url 参数显式配置,不要改变默认值。同时更新 tests/test_connection_config.py 中对应断言。

likedislike
Incorrect?
atomgit-bot
atomgit-botAug 28Start code review1
py-sdk/e2b/connection_config.py
@@ -115,3 +115,3 @@
115115 api_url
116116 or ConnectionConfig._api_url()
117- or ("http://localhost:3000" if self.debug else f"https://api.{self.domain}")
117+ or ("http://localhost:3000" if self.debug else f"http://api.{self.domain}")
atomgit-bot
atomgit-botAug 28Comments:

🟡 Medium Priority

变更行:connection_config.py:117 把默认 api_url 由 https://api.<domain> 改为 http://api.<domain>,但本 diff 未同步修改测试。

受影响行为/契约:现有测试 tests/test_connection_config.py:8(test_api_url_defaults_correctly)在 E2B_DOMAIN=""、非 debug 下断言 config.api_url == "https://api.e2b.app"。改动后 _domain() 回退到 "e2b.app"、debug=False,新默认值为 "http://api.e2b.app"。

失败模式:断言必然失败,CI 测试套件回归;同一文件内的默认值契约与既有测试不一致。

建议:要么恢复 https 默认值,要么同步更新 tests/test_connection_config.py 中断言为 http://api.e2b.app 并核对 custom_domain 等用例。

likedislike
Incorrect?
openeuler-ci-botopeneuler-ci-botCollaborators
Aug 28 Removed label: ci_processing
openeuler-ci-bot
openeuler-ci-botCollaborators
Aug 28 Comments:
Check Name Build Result 详情 Build Details
check_sca ✅SUCCESS #247
check_package_license ✅SUCCESS
x86_64 check_build ✅SUCCESS #250
aarch64 check_build ✅SUCCESS #266
DT check_build ✅SUCCESS #263
likedislike
openeuler-ci-botopeneuler-ci-botCollaborators
Aug 28 Added label: ci_successful
openeuler-ci-bot
openeuler-ci-botCollaborators
Aug 28 Comments:
likedislike
zhourenjian
zhourenjianCollaborators
Aug 28 Comments:

/lgtm
/approve

likedislike
openeuler-ci-botopeneuler-ci-botCollaborators
Aug 28 Added label: approvedlgtm
openeuler-ci-bot
openeuler-ci-botCollaborators
Aug 28 Comments:

Review Code Feedback

  • The label lgtm, approved was added to this pull request. It means that zhourenjianz reviewed the code changes. 👋
Tips
  • If this pull request is not merged while all conditions are met, comment /check-pr to try again. 😄
likedislike
openeuler-ci-botopeneuler-ci-botCollaborators
Aug 28 Merged pull request, merge node SHA: e43e0b8bbcb490073737bdf66a434cf988a43ce5