fix(general): 配置拷贝四处补齐源存在性判断 - #616
Open
qiyinxi wants to merge 1 commit into
Open
Conversation
同一套「按 ConfigPathMode 在两个目录间拷贝」的逻辑在通用脚本里写了 4 份, 只有 ScriptConfig.set_general 一份做了存在性判断(e457f397 加的),另外三处 没有同步,源不存在就直接抛 FileNotFoundError 并把任务判成异常。 - AutoProxy.set_general: 补齐判断,源不存在时沿用脚本自身配置,与 ScriptConfig.set_general 行为一致 - AutoProxy.update_config / ScriptConfig.final_task: 回写方向源不存在时跳过 并给出可读提示,且提前返回以免把已有备份先删掉 - AutoProxy.update_config 的 File 分支补 mkdir(parents=True),Folder 分支靠 copytree 自建目录本就不受影响 Closes AUTO-MAS-Project#533 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
审查者指南该 PR 为所有剩余的通用脚本配置复制路径添加了缺失的源存在性检查。现在,如果用户配置缺失,则回退到脚本配置;如果脚本配置缺失,则跳过写回操作,同时不会删除现有的用户备份;此外,文件模式的目标路径也会在复制前创建。 带源存在性检查的通用脚本配置同步时序图sequenceDiagram
participant Script as ScriptConfig
participant Proxy as AutoProxy
participant UserConfig as UserConfigDir
participant ScriptPath as ScriptConfigPath
Script->>UserConfig: set_general()
alt user config exists
UserConfig-->>Script: exists
Script->>ScriptPath: shutil.copy or shutil.copytree
else user config missing
UserConfig-->>Script: missing
Script-->>Script: preserve script configuration
end
Proxy->>ScriptPath: update_config() / final_task()
alt script config missing
ScriptPath-->>Proxy: missing
Proxy-->>Proxy: log warning and return
else script config exists
Proxy->>UserConfig: remove or create destination
Proxy->>UserConfig: shutil.copy or shutil.copytree
end
文件级变更
可能关联的问题
提示和命令与 Sourcery 交互
自定义你的使用体验访问你的控制面板以:
获取帮助Original review guide in EnglishReviewer's GuideThe PR adds missing source-existence guards to all remaining general-script configuration copy paths. Missing user configuration now falls back to the script’s configuration, while missing script configuration skips write-back without removing existing user backups; file-mode destinations are also created before copying. Sequence diagram for guarded general-script configuration synchronizationsequenceDiagram
participant Script as ScriptConfig
participant Proxy as AutoProxy
participant UserConfig as UserConfigDir
participant ScriptPath as ScriptConfigPath
Script->>UserConfig: set_general()
alt user config exists
UserConfig-->>Script: exists
Script->>ScriptPath: shutil.copy or shutil.copytree
else user config missing
UserConfig-->>Script: missing
Script-->>Script: preserve script configuration
end
Proxy->>ScriptPath: update_config() / final_task()
alt script config missing
ScriptPath-->>Proxy: missing
Proxy-->>Proxy: log warning and return
else script config exists
Proxy->>UserConfig: remove or create destination
Proxy->>UserConfig: shutil.copy or shutil.copytree
end
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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 #533
问题
通用脚本里「按
ConfigPathMode在 MAS 数据目录与脚本自身配置路径之间拷贝」这套逻辑写了 4 份,只有ScriptConfig.set_general一份做了存在性判断(e457f397加的),另外三处没同步,源不存在就直接抛FileNotFoundError,任务被判成「异常」。Sentry 上三条:
AUTO-MAS-BACKEND-4Q(4 条)、4Y(9 条)、4W(8 条),合计 21 条、至少 2 名用户。改动
AutoProxy.set_generalScriptConfig.set_general行为对齐AutoProxy.update_configmkdir(parents=True, exist_ok=True)ScriptConfig.final_task两处回写的早退都放在
shutil.rmtree(用户配置目录)之前——原来的顺序是先删备份再拷贝,源不存在时会先把用户已有的备份删掉、然后抛异常,用户看起来就是「配置丢了」。现在源不存在时备份原样保留。两处早退都不会跳过别的收尾:
ScriptConfig.final_task的回写本就是函数最后一段,AutoProxy.update_config是自包含函数,调用方(AutoProxy.py:499/:522)后续流程不受影响。顺带把重复出现四次的
Path.cwd() / f"data/{script_id}/{uid}/ConfigFile"收进局部变量,只在本次改到的两个函数里做,没有扩散到别处。本地验证
没有加自动化测试:按仓库
tests/AGENTS.md,bug 边界测试只在本地验证、不提交。没有做真机手测:触发这三条路径需要装一个通用脚本并造出「用户还没跑过脚本设置」「ConfigPath 指向不存在的文件」两种状态,本地没有环境。改动是纯粹的前置判断,不改任何拷贝语义,但建议合并前由熟悉这块的人确认一下「源不存在时沿用脚本自身配置」这个取舍符合预期——这是我按
ScriptConfig.set_general的既有行为推定的,issue 里也是这么判的。请审阅
@DLmaster361 这块是你写的。确认后请你自行合并,我不代合。
Sourcery 总结
在通用脚本配置同步路径中安全处理缺失的配置源。
错误修复:
功能增强:
Original summary in English
Summary by Sourcery
Handle missing configuration sources safely across general-script configuration synchronization paths.
Bug Fixes:
Enhancements: