fix: pass plugin name to StarTools.get_data_dir() to avoid inspect.stack() crash#123
Open
Rat0323 wants to merge 1 commit into
Open
fix: pass plugin name to StarTools.get_data_dir() to avoid inspect.stack() crash#123Rat0323 wants to merge 1 commit into
Rat0323 wants to merge 1 commit into
Conversation
6e1cb7e to
b9df10b
Compare
Author
|
抱歉,之前的提交中由于本地开发分支污染,不小心夹带了部分非预期的本地测试代码。我刚才已通过 git push --force 重新整理了提交,移除了全部多余的本地测试指令和交互逻辑,仅保留了此 PR 描述中所涉及的最简纯净修复逻辑。非常抱歉给您带来不便,现在已可以正常 review 和合并! |
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.
Problem
When
StarTools.get_data_dir()is called without arguments, the framework attempts to deduce the calling plugin name usinginspect.stack(). Under certain environments (such as dynamic reloading, testing shims, or direct scripts where__main__is the entrypoint), metadata extraction fails, throwing a fatalRuntimeError: 无法获取模块 __main__ 的元信息.Solution
Explicitly pass the plugin name
"astrbot_plugin_self_evolution"to the call ofStarTools.get_data_dir()inmain.pyto avoid this dynamic inspection crash. This is safe, backwards-compatible, and robust across all execution environments.Validation
💡 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.