Skip to content

fix: created unnecessary data dir when executing astrbot command - #8932

Merged
Soulter merged 2 commits into
masterfrom
fix/8853
Jun 21, 2026
Merged

Soulter merged 2 commits into
masterfrom
fix/8853

Conversation

@Soulter

@Soulter Soulter commented Jun 21, 2026 •

Copy link
Copy Markdown
Member

fixes: #8853

Modifications / 改动点

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果


Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。

  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txt 和 pyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Align version management with astrbot.version and adjust CLI behavior around initialization and dashboard setup.

Bug Fixes:

  • Prevent the astrbot command from creating an unnecessary data directory when running initialization.
  • Fix dashboard password validation and hashing by importing the correct utility functions locally in CLI commands.
  • Avoid aborting the CLI flow when the user declines dashboard installation during initialization.

Enhancements:

  • Centralize project version definition in astrbot.init.version and expose it via astrbot.cli.version.
  • Update release and contribution documentation to reflect the new versioning scheme and prepare_release script behavior.

@vercel

vercel Bot commented Jun 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astr-bot Ready Ready Preview, Comment Jun 21, 2026 6:05am

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. area:core The bug / feature is about astrbot's core, backend labels Jun 21, 2026

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request refactors version management by defining __version__ in astrbot/__init__.py and deriving VERSION in astrbot/core/config/default.py from it. It also defers several imports in CLI commands to optimize startup and removes abort=True from a confirmation prompt. However, the release preparation script (scripts/prepare_release.py) needs to be updated to modify __version__ in astrbot/__init__.py instead of default.py to prevent execution failures.

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.

Comment thread astrbot/core/config/default.py

@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, and left some high level feedback:

  • The move of several imports (e.g., check_dashboard, get_astrbot_root, password helpers) inside functions appears to be addressing initialization side effects; consider adding a brief code comment to clarify that these are intentionally lazy imports to avoid unintended directory creation so future refactors don’t move them back to the module level.
  • Removing abort=True from click.confirm in check_dashboard changes the behavior when the user declines installation; if this is intentional, it might be clearer to explicitly handle the False case (e.g., logging and returning early) so the flow is obvious and no follow-up logic runs unexpectedly.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The move of several imports (e.g., `check_dashboard`, `get_astrbot_root`, password helpers) inside functions appears to be addressing initialization side effects; consider adding a brief code comment to clarify that these are intentionally lazy imports to avoid unintended directory creation so future refactors don’t move them back to the module level.
- Removing `abort=True` from `click.confirm` in `check_dashboard` changes the behavior when the user declines installation; if this is intentional, it might be clearer to explicitly handle the `False` case (e.g., logging and returning early) so the flow is obvious and no follow-up logic runs unexpectedly.

## Individual Comments

### Comment 1
<location path="astrbot/cli/utils/basic.py" line_range="42-45" />
<code_context>
                 if click.confirm(
                     "Install dashboard?",
                     default=True,
-                    abort=True,
                 ):
                     click.echo("Installing dashboard...")
                     await download_dashboard(
</code_context>
<issue_to_address>
**issue (bug_risk):** Removing `abort=True` changes the control flow on a negative answer and may leave the dashboard uninstalled while continuing execution.

Without `abort=True`, answering "no" now just skips `download_dashboard` and continues initialization. If later steps assume the dashboard exists or depend on a hard failure when it doesn’t, this can result in partial setups or hard-to-diagnose errors. If you want to support running without the dashboard, please handle the "no" case explicitly (e.g., log a clear message or return early).
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread astrbot/cli/utils/basic.py
@Soulter
Soulter merged commit 39d4253 into master Jun 21, 2026
20 of 22 checks passed
KBVsent pushed a commit to KBVsent/AstrBot that referenced this pull request Jul 13, 2026
…rBotDevs#8932)

* fix: created unnecessary data dir when executing astrbot command

fixes: AstrBotDevs#8853

* fix: 更新包版本更新函数以修改 astrbot/__init__.py 中的版本号
KBVsent pushed a commit to KBVsent/AstrBot that referenced this pull request Jul 13, 2026
…rBotDevs#8932)

* fix: created unnecessary data dir when executing astrbot command

fixes: AstrBotDevs#8853

* fix: 更新包版本更新函数以修改 astrbot/__init__.py 中的版本号

This branch was successfully deployed

1 active deployment
Preview — e258d5ea Deployed Jun 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core The bug / feature is about astrbot's core, backend size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] astrbot init 选不在当前路径安装,报错并残留data文件夹

1 participant