fix: 补齐 updater bundler 配置并加固元数据生成#65
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此 PR 旨在提升桌面应用程序构建和发布流程的稳定性与健壮性。它解决了 updater bundler 在配置公钥时的兼容性问题,增强了 updater 元数据生成脚本的容错能力,并修复了后端 HTTP 测试辅助函数中的一个潜在缓冲区安全漏洞,从而确保了更可靠的开发和部署体验。 Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Hey - 我发现了 1 个问题,并给出了一些整体性的反馈:
- 在
collect_platforms中,新添加的print(f"[generate-tauri-latest-json] Ignoring unsupported signature file: {sig_name}", ...)放在各平台分支处理之后且是无条件执行的;按当前写法,它也会对已成功解析的签名运行(除非前面的分支continue),因此建议通过显式的elif/else或一个handled标志来重构逻辑,以确保只有真正未识别的.sig文件才会触发“unsupported”警告。
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `collect_platforms` the new `print(f"[generate-tauri-latest-json] Ignoring unsupported signature file: {sig_name}", ...)` is unconditional after the platform-specific handling; as written it will also run for successfully parsed signatures (unless earlier branches `continue`), so consider restructuring with explicit `elif`/`else` or a `handled` flag to ensure the "unsupported" warning only fires for truly unrecognized `.sig` files.
## Individual Comments
### Comment 1
<location path="scripts/ci/generate-tauri-latest-json.py" line_range="70-75" />
<code_context>
- raise ValueError(
- "Unexpected macOS artifact name: "
- f"{zip_name}. Expected format: <name>_<version>_macos_<arch>.zip"
+ print(
+ "[generate-tauri-latest-json] Ignoring unrecognized macOS signature file: "
+ f"{zip_name}. Expected format: <name>_<version>_macos_<arch>.zip",
+ file=sys.stderr,
)
+ continue
platform_key = platform_key_for_macos(match.group("arch"))
platforms[platform_key] = {
</code_context>
<issue_to_address>
**issue (bug_risk):** Soft-failing on malformed macOS artifact names may hide CI/configuration issues.
Previously, an unexpected macOS artifact name caused the job to fail, making misconfigurations visible. Now we only log and continue, which can silently omit a platform from `latest.json` and cause users on that platform to miss updates.
If we need to ignore noise artifacts, we could instead tighten the matching (e.g., stricter pattern or allowlist) and still fail on truly invalid names, or at least exit non‑zero when no valid macOS artifacts are found.
</issue_to_address>帮我变得更有用!请对每条评论点 👍 或 👎,我会根据你的反馈改进评审质量。
Original comment in English
Hey - I've found 1 issue, and left some high level feedback:
- In
collect_platformsthe newprint(f"[generate-tauri-latest-json] Ignoring unsupported signature file: {sig_name}", ...)is unconditional after the platform-specific handling; as written it will also run for successfully parsed signatures (unless earlier branchescontinue), so consider restructuring with explicitelif/elseor ahandledflag to ensure the "unsupported" warning only fires for truly unrecognized.sigfiles.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `collect_platforms` the new `print(f"[generate-tauri-latest-json] Ignoring unsupported signature file: {sig_name}", ...)` is unconditional after the platform-specific handling; as written it will also run for successfully parsed signatures (unless earlier branches `continue`), so consider restructuring with explicit `elif`/`else` or a `handled` flag to ensure the "unsupported" warning only fires for truly unrecognized `.sig` files.
## Individual Comments
### Comment 1
<location path="scripts/ci/generate-tauri-latest-json.py" line_range="70-75" />
<code_context>
- raise ValueError(
- "Unexpected macOS artifact name: "
- f"{zip_name}. Expected format: <name>_<version>_macos_<arch>.zip"
+ print(
+ "[generate-tauri-latest-json] Ignoring unrecognized macOS signature file: "
+ f"{zip_name}. Expected format: <name>_<version>_macos_<arch>.zip",
+ file=sys.stderr,
)
+ continue
platform_key = platform_key_for_macos(match.group("arch"))
platforms[platform_key] = {
</code_context>
<issue_to_address>
**issue (bug_risk):** Soft-failing on malformed macOS artifact names may hide CI/configuration issues.
Previously, an unexpected macOS artifact name caused the job to fail, making misconfigurations visible. Now we only log and continue, which can silently omit a platform from `latest.json` and cause users on that platform to miss updates.
If we need to ignore noise artifacts, we could instead tighten the matching (e.g., stricter pattern or allowlist) and still fail on truly invalid names, or at least exit non‑zero when no valid macOS artifacts are found.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| print( | ||
| "[generate-tauri-latest-json] Ignoring unrecognized macOS signature file: " | ||
| f"{zip_name}. Expected format: <name>_<version>_macos_<arch>.zip", | ||
| file=sys.stderr, | ||
| ) | ||
| continue |
There was a problem hiding this comment.
issue (bug_risk): 对格式错误的 macOS 制品名称进行“软失败”处理,可能会掩盖 CI / 配置问题。
之前,遇到意外的 macOS 制品名称会导致任务失败,从而暴露配置错误。现在我们只记录日志并继续执行,这可能会悄悄地在 latest.json 中漏掉某个平台,导致该平台的用户收不到更新。
如果确实需要忽略噪声制品,可以考虑收紧匹配条件(例如更严格的模式或白名单),同时仍然对真正无效的名称失败,或者在未找到任何有效的 macOS 制品时至少以非零状态退出。
Original comment in English
issue (bug_risk): Soft-failing on malformed macOS artifact names may hide CI/configuration issues.
Previously, an unexpected macOS artifact name caused the job to fail, making misconfigurations visible. Now we only log and continue, which can silently omit a platform from latest.json and cause users on that platform to miss updates.
If we need to ignore noise artifacts, we could instead tighten the matching (e.g., stricter pattern or allowlist) and still fail on truly invalid names, or at least exit non‑zero when no valid macOS artifacts are found.
There was a problem hiding this comment.
Code Review
这个 PR 的修改方向是正确的,有效地提升了 updater 功能的稳定性和代码的健壮性。主要有三点:
- 将 updater 的
pubkey配置从运行时环境注入改为在tauri.conf.json中静态配置,简化了逻辑,统一了配置来源。 - 增强了
generate-tauri-latest-json.py脚本,使其在遇到无法识别的签名文件时能够打印警告并继续执行,而不是直接失败。这是一个很好的健壮性提升。 - 修复了
src-tauri/src/backend/http.rs中测试辅助工具TimeoutReader的一个缓冲区溢出隐患,提升了测试代码的安全性。
代码修改清晰,符合 PR 描述。我有一个关于 generate-tauri-latest-json.py 脚本一致性的小建议,请查看具体的 review comment。
| if not match: | ||
| raise ValueError( | ||
| "Unexpected macOS artifact name: " | ||
| f"{zip_name}. Expected format: <name>_<version>_macos_<arch>.zip" | ||
| print( | ||
| "[generate-tauri-latest-json] Ignoring unrecognized macOS signature file: " | ||
| f"{zip_name}. Expected format: <name>_<version>_macos_<arch>.zip", | ||
| file=sys.stderr, | ||
| ) | ||
| continue |
|
@sourcery-ai review |
概述
这个 PR 基于已合并的桌面运行时重构与 updater 接入工作,补充两个后续修复:
变更内容
1. 修复 updater bundler 对
pubkey的配置要求Tauri bundler 在解析 updater 配置时要求
tauri.conf.json中显式存在plugins.updater.pubkey。此前仅靠 runtime 侧动态注入并不能满足 bundler 的解析阶段,因此本地make build会在 bundler settings 阶段失败。这个 PR:
src-tauri/tauri.conf.json中显式配置 updaterpubkeysrc-tauri/src/app_runtime.rs中冗余的 runtime 环境变量注入逻辑这样配置来源更单一,也避免 bundler 和 runtime 对 pubkey 来源理解不一致。
2. 加固 updater metadata 生成脚本
scripts/ci/generate-tauri-latest-json.py现在:.sig工件改为忽略并输出 warning,而不是直接让整个 release job 失败这可以避免未来 release 目录里新增其他签名资产时,
latest.json生成被非 updater 工件误伤。3. 修复 backend HTTP 测试 helper 的缓冲区安全问题
src-tauri/src/backend/http.rs中的TimeoutReader测试 helper 现在会按buf.len()截断复制长度,避免在不同缓冲区大小下潜在的越界 panic。验证
cargo test --manifest-path src-tauri/Cargo.toml --lockedpnpm run test:prepare-resourcescargo fmt --manifest-path src-tauri/Cargo.toml --all -- --checkpython3 -m py_compile scripts/ci/generate-tauri-latest-json.pymake build已越过 updaterpubkey缺失导致的 bundler 配置报错Summary by Sourcery
稳定 Tauri 更新程序(updater)的配置,并强化相关工具和测试,以实现更安全的构建和发布流程。
Bug 修复:
TimeoutReader测试辅助工具,使其遵守目标缓冲区大小,避免潜在的越界 panic。增强:
构建:
tauri.conf.json中 updater 打包器(bundler)的配置,使打包在不同环境中都能稳定成功。CI:
测试:
TimeoutReader辅助工具中的缓冲区处理方式,提高后端 HTTP 测试的可靠性。Original summary in English
Summary by Sourcery
Stabilize the Tauri updater configuration and harden associated tooling and tests for safer builds and releases.
Bug Fixes:
Enhancements:
Build:
CI:
Tests:
Bug 修复:
tauri.conf.json中使用静态定义的公钥,使本地和 CI 构建不再因缺少公钥而失败。TimeoutReaderHTTP 测试辅助工具,使其遵守目标缓冲区大小,避免潜在的越界 panic。增强功能:
tauri.conf.json中的配置,而不是运行时环境变量。Original summary in English
Summary by Sourcery
稳定 Tauri 更新程序(updater)的配置,并强化相关工具和测试,以实现更安全的构建和发布流程。
Bug 修复:
TimeoutReader测试辅助工具,使其遵守目标缓冲区大小,避免潜在的越界 panic。增强:
构建:
tauri.conf.json中 updater 打包器(bundler)的配置,使打包在不同环境中都能稳定成功。CI:
测试:
TimeoutReader辅助工具中的缓冲区处理方式,提高后端 HTTP 测试的可靠性。Original summary in English
Summary by Sourcery
Stabilize the Tauri updater configuration and harden associated tooling and tests for safer builds and releases.
Bug Fixes:
Enhancements:
Build:
CI:
Tests: