fix: guard packaged AstrBot runtime version#140
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds runtime version validation for AstrBot during the resource preparation phase. It introduces helper functions to extract the version from default.py and verify it against the version specified in pyproject.toml, raising errors for mismatches or unresolved '0.0.0' versions. Corresponding unit tests have also been implemented to cover these scenarios. There are no review comments, and I have no additional feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In
validateAstrbotRuntimeVersion, the return value ofruntimeVersionis currently unused by its only caller; consider either returningvoidor wiring the returned value through to avoid suggesting it is meaningful output. - The logic for locating the runtime version file (
astrbot/core/config/default.py) is now duplicated between the implementation and tests; consider pulling the path construction into a small helper or constant to avoid drift if the layout changes.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `validateAstrbotRuntimeVersion`, the return value of `runtimeVersion` is currently unused by its only caller; consider either returning `void` or wiring the returned value through to avoid suggesting it is meaningful output.
- The logic for locating the runtime version file (`astrbot/core/config/default.py`) is now duplicated between the implementation and tests; consider pulling the path construction into a small helper or constant to avoid drift if the layout changes.
## Individual Comments
### Comment 1
<location path="scripts/prepare-resources.mjs" line_range="64-65" />
<code_context>
const astrbotVersion =
desktopVersionOverride || (await readAstrbotVersionFromPyproject({ sourceDir }));
+ if (!desktopVersionOverride) {
+ await validateAstrbotRuntimeVersion({ sourceDir, expectedVersion: astrbotVersion });
+ }
+
</code_context>
<issue_to_address>
**question (bug_risk):** Consider validating runtime VERSION even when a desktopVersionOverride is supplied, at least for the 0.0.0 guard.
Because `validateAstrbotRuntimeVersion` is only called when `desktopVersionOverride` is unset, a runtime VERSION of `0.0.0` (or drift from `pyproject`) is silently accepted whenever an override is used, despite the error text implying `0.0.0` is always invalid. To align behavior with the messaging, consider always enforcing at least the `0.0.0` (and maybe drift) checks even when an override is present, or clarify in the code/message that overrides bypass these checks.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| if (!desktopVersionOverride) { | ||
| await validateAstrbotRuntimeVersion({ sourceDir, expectedVersion: astrbotVersion }); |
There was a problem hiding this comment.
question (bug_risk): Consider validating runtime VERSION even when a desktopVersionOverride is supplied, at least for the 0.0.0 guard.
Because validateAstrbotRuntimeVersion is only called when desktopVersionOverride is unset, a runtime VERSION of 0.0.0 (or drift from pyproject) is silently accepted whenever an override is used, despite the error text implying 0.0.0 is always invalid. To align behavior with the messaging, consider always enforcing at least the 0.0.0 (and maybe drift) checks even when an override is present, or clarify in the code/message that overrides bypass these checks.
Summary
Why
AstrBot core briefly derived VERSION dynamically and could fall back to 0.0.0 in packaged desktop resource layouts. Core has restored a static VERSION, but desktop builds should still fail before producing artifacts if the selected AstrBot source ref has a broken or mismatched runtime version.
Testing
Co-Authored-By: OpenCode opencode@local
Summary by Sourcery
Guard AstrBot desktop resource preparation by validating the packaged runtime VERSION against pyproject.toml and failing early on invalid or mismatched versions.
New Features:
Tests: