Pull Request has been successfully merged by openeuler-ci-bot.
(Thank you for fly_1997's contribution.)变更摘要
本 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文件。


代码审查
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 |
⛔ 需要修改


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 .


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


🟡 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 断言,保证测试与新契约一致。


🟠 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 中对应断言。


🟡 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 等用例。


/lgtm
/approve


当前PR是否有AI参与:
[x] 否
[ ] 是
__1. AI Agent 平台:
__2. AI 模型:
__3. Prompt上下文 :
参考:openEuler社区《生成式AI工具使用与开源贡献政策》
PR功能描述 / 为什么需要这个合入**:
该PR关联的issue
(格式为fixes #<issue号>, 或者resolves #<issue号>): fixes #
希望检视人员了解: