Skip to content

fix: pass plugin name to StarTools.get_data_dir() to avoid inspect.stack() crash#123

Open
Rat0323 wants to merge 1 commit into
Renyus:masterfrom
Rat0323:fix-get-data-dir-crash
Open

fix: pass plugin name to StarTools.get_data_dir() to avoid inspect.stack() crash#123
Rat0323 wants to merge 1 commit into
Renyus:masterfrom
Rat0323:fix-get-data-dir-crash

Conversation

@Rat0323

@Rat0323 Rat0323 commented Jun 5, 2026

Copy link
Copy Markdown

Problem

When StarTools.get_data_dir() is called without arguments, the framework attempts to deduce the calling plugin name using inspect.stack(). Under certain environments (such as dynamic reloading, testing shims, or direct scripts where __main__ is the entrypoint), metadata extraction fails, throwing a fatal RuntimeError: 无法获取模块 __main__ 的元信息.

Solution

Explicitly pass the plugin name "astrbot_plugin_self_evolution" to the call of StarTools.get_data_dir() in main.py to avoid this dynamic inspection crash. This is safe, backwards-compatible, and robust across all execution environments.

Validation

  • Verified and tested successfully under AstrBot official environment.

💡 Ecosystem & Framework Context

This issue stems from a known vulnerability in the AstrBot core framework's path-resolving API. We have submitted a root-cause fix to the official AstrBot core repository: AstrBot Core PR #8588.

However, this plugin-level change (passing the plugin name explicitly) remains highly necessary to ensure backward compatibility. It prevents the plugin from crashing on older installations of AstrBot that have not upgraded to the latest core version.

This is a safe, non-breaking, and recommended change.

@Rat0323 Rat0323 force-pushed the fix-get-data-dir-crash branch from 6e1cb7e to b9df10b Compare June 5, 2026 11:14
@Rat0323

Rat0323 commented Jun 5, 2026

Copy link
Copy Markdown
Author

抱歉,之前的提交中由于本地开发分支污染,不小心夹带了部分非预期的本地测试代码。我刚才已通过 git push --force 重新整理了提交,移除了全部多余的本地测试指令和交互逻辑,仅保留了此 PR 描述中所涉及的最简纯净修复逻辑。非常抱歉给您带来不便,现在已可以正常 review 和合并!

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