Repository navigation
fix: avoid shadowing the .astrbot marker file in the system temp dir - #10784
Merged
Soulter merged 5 commits intoOct 26, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
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/utils/astrbot_path.py" line_range="106" />
<code_context>
+ system_tmp = Path(tempfile.gettempdir())
+ candidate = system_tmp / ".astrbot"
+ if candidate.is_file():
+ candidate = system_tmp / ".astrbot-tmp"
+ return os.path.realpath(str(candidate))
</code_context>
<issue_to_address>
**Temporary data enters images**
When the system temp directory falls back to the repository root and a Docker build runs while temporary files remain there, `Dockerfile` copies the build context with `COPY . /AstrBot/`, while `.dockerignore` excludes `.astrbot` but not `.astrbot-tmp`; temporary files created under the new path, including background shell logs, are therefore embedded in built images and exposed to anyone with access to them.
Add `.astrbot-tmp` to both `.dockerignore` and `.gitignore`.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: astrbot/core/utils/astrbot_path.py:106
sourcery-ai
Bot
dismissed
their stale review
October 26, 2026 14:53
Sourcery withdrew this approval because the latest commits introduced blocking findings.
Soulter
approved these changes
Oct 26, 2026
Soulter
approved these changes
Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #10783
Problem
get_astrbot_system_tmp_path()joins.astrbotontotempfile.gettempdir(). When the system temporary directory is unusable, Python falls back to the current working directory — the directory whereastrbot initleaves the.astrbotmarker file. The plugin installer then does:which raises
FileExistsError: [Errno 17] File exists: '/AstrBot/.astrbot'before the plugin is even downloaded.This is the collision case the issue separates from the deployment problem: the unusable system temp dir is an environment issue, but AstrBot must not fail with a bare
FileExistsErrorbecause its own marker file happens to sit at the resolved path.Fix
get_astrbot_system_tmp_path()now checks whether the resolved.astrbotpath is an existing file (the init marker). In that case it returns a sibling directory instead, so the marker file is never shadowed by a directory:The normal case is unchanged: the shared directory is still
<system temp>/.astrbot.Tests
tests/test_astrbot_path.py(new): the shared directory stays<system temp>/.astrbotwhen that path is free or already a directory, and never resolves to the init marker file when that path is a regular file.tests/test_plugin_manager.py:install_plugin()completes when the system temp dir contains the.astrbotmarker file, and the marker file is left intact.Red/green on the change:
ruff formatandruff checkare clean on the changed files.Summary by Sourcery
Prevent temporary-directory handling from shadowing AstrBot’s initialization marker file.
Bug Fixes:
.astrbotinitialization marker file.Enhancements:
.astrbot-tmpdirectory when.astrbotis an existing file while preserving the normal temporary-directory behavior.Tests:
Chores:
.astrbot-tmpdirectory in Git and Docker builds.