Skip to content

feat(updater): prefer CERNET PyPI source packages for releases - #10041

Open
Soulter wants to merge 1 commit into
masterfrom
codex/pypi-mirror-update
Open

feat(updater): prefer CERNET PyPI source packages for releases#10041
Soulter wants to merge 1 commit into
masterfrom
codex/pypi-mirror-update

Conversation

@Soulter

@Soulter Soulter commented Sep 11, 2026

Copy link
Copy Markdown
Member

Release updates currently download Core and WebUI separately from hosted storage or GitHub. First check the CERNET PyPI mirror for the exact release's source distribution and use both its source tree and astrbot/dashboard/dist when the package is valid.

  • Resolve relative download links after mirror redirects, skip yanked releases, and verify SHA-256, archive paths, package metadata, and bundled WebUI compatibility before applying files.
  • Fall back to the existing Core and Dashboard sources if the version is missing or mirror download/preparation fails. Preserve the configured GitHub proxy and commit-based update path.
  • Keep CLI/launcher-managed installations on their existing package-manager update path.

Based directly on master, independently of the workspace preview changes. Includes regression coverage for mirror success, fallback, archive validation, and update restrictions.

Validation: tests were not rerun for this PR, as requested by the maintainer.

Summary by Sourcery

Prefer validated CERNET PyPI packages for release updates while retaining safe fallback and existing installation-specific update paths.

New Features:

  • Prefer validated CERNET PyPI source distributions, including their bundled Dashboard assets, when applying release updates.

Bug Fixes:

  • Fall back safely to the existing Core and Dashboard download sources when mirror packages are unavailable or invalid.
  • Prevent CLI- and launcher-managed installations from using the in-app updater.

Enhancements:

  • Add validation for mirror links, release metadata, archive integrity and safety, package hashes, and WebUI compatibility while preserving commit-based updates and configured GitHub proxies.

Tests:

  • Add regression coverage for successful mirror updates, fallback scenarios, archive validation, commit updates, and managed-install restrictions.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
astrbot-docs 9af89d4 Commit Preview URL

Branch Preview URL
Sep 11 2026, 04:41 AM

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="astrbot/core/updater.py" line_range="265-337" />
<code_context>
+                    "Checking the PyPI mirror for the update...",
+                    0,
+                )
+                mirror_prepared = await self._download_pypi_package(
+                    target_version,
+                    core_zip_path,
+                    dashboard_zip_path,
+                    progress_callback=dashboard_progress,
</code_context>
<issue_to_address>
**nitpick:** The PyPI source-distribution download reports every progress payload through `dashboard_progress`, so the source download is presented as WebUI progress and no Core download progress is emitted while the Core archive is being fetched and prepared.

**Triggers:** When a progress callback is supplied during a successful PyPI mirror update.

**Suggested fix:** Use a distinct Core progress callback for the source download, or emit separate progress events for the source and bundled Dashboard preparation.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. The updater now makes the CERNET mirror a trusted source for executable AstrBot code and bundled assets, with the mirror supplying both the archive and its SHA-256 digest. If that trust decision or package is wrong, users can persistently install incorrect or malicious code; reverting the updater would not undo files already installed.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread astrbot/core/updater.py
Comment on lines +265 to 337
mirror_prepared = await self._download_pypi_package(
target_version,
core_zip_path,
dashboard_zip_path,
progress_callback=dashboard_progress,
)
if mirror_prepared:
await emit_progress(
"dashboard", "done", "Bundled WebUI prepared from PyPI.", 45
)
await emit_progress(
"core", "done", "AstrBot source prepared from PyPI.", 90
)
else:
if target_version.startswith("v") and target_release is None:
releases = await self._fetch_release_info(self._release_api)
target_release = next(
(
release
for release in releases
if release["tag_name"] == target_version
),
None,
)
if target_release is None:
raise RuntimeError(
f"No update package was found for version {target_version}."
)

await emit_progress(
"dashboard",
"running",
"正在下载 WebUI...",
0,
)
await _download_package(
path=str(dashboard_zip_path),
version=target_version,
proxy=proxy,
progress_callback=dashboard_progress,
extract=False,
allow_insecure_ssl_fallback=False,
)
await emit_progress(
"dashboard",
"done",
"WebUI 下载完成。",
45,
)

await emit_progress(
"core",
"running",
"正在下载 AstrBot 项目代码...",
45,
)
await self._download_core_package(
latest=False,
version=target_version,
proxy=proxy,
path=core_zip_path,
progress_callback=core_progress,
release_data=target_release,
)
await emit_progress(
"core",
"done",
"项目代码下载完成。",
90,
)
await emit_progress(
"core",
"running",
"正在下载 AstrBot 项目代码...",
45,
)
await self._download_core_package(
latest=False,
version=target_version,
proxy=proxy,
path=core_zip_path,
progress_callback=core_progress,
release_data=target_release,
)
await emit_progress(
"core",
"done",
"项目代码下载完成。",
90,
)

await emit_progress(
"verify",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick: The PyPI source-distribution download reports every progress payload through dashboard_progress, so the source download is presented as WebUI progress and no Core download progress is emitted while the Core archive is being fetched and prepared.

Triggers: When a progress callback is supplied during a successful PyPI mirror update.

Suggested fix: Use a distinct Core progress callback for the source download, or emit separate progress events for the source and bundled Dashboard preparation.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant