fix: propagate script errors instead of silently swallowing them - #4
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
fix: propagate script errors instead of silently swallowing them#4devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Summary
审计了仓库里所有脚本(
99script/*、10ccdaily/scripts/*)的错误处理,修掉了错误被吞掉或不向外传播的地方。最危险的一处会覆盖用户已有的 crontab:crontab -l在“当前用户没有 crontab”时返回非 0,原来的代码把任何非 0 都当成空内容:现在
read_existing_crontab()(Python)/read_existing_crontab+has_no_crontab(Bash)只在 stderr 含no crontab时视为空,其他失败一律终止安装并保留原 crontab;写入crontab -失败也会带上 stderr 报错,而不是抛一个不含输出的CalledProcessError。其余修复:
git_auto.shlog()不再因日志文件/目录不可写而让整个脚本失败:降级为只写 stderr 并 WARN 一次(原本mkdir -p ... | tee失败会在set -e/pipefail下静默终止任何一步)。ERRtrap,set -e触发的退出会打印exit 码 + 行号 + 失败命令,不再无声退出。fetch/pull/stash push/add/commit/push前的重新同步、mkdir、heartbeat 文件写入、exec 9>lockfile、chmod +x)都补上了带上下文的die信息;pull冲突时先rebase --abort/merge --abort再报错,不留半完成状态。--status的 fetch 从>/dev/null 2>&1改为捕获并打印 git 的真实错误输出。install_cron/uninstall_cron去掉mktemp(失败路径会泄漏临时文件),改为内存中拼装。REPO_DIR改为${REPO_DIR:-...},与帮助文本里REPO_DIR=/abs/path $0 --run的用法一致。daily_report.py:输出目录/文件的OSError变成明确的SystemExit提示;--install-cron会先创建输出目录,否则 cron 每次的重定向都会静默失败。update_repo.sh:set -e→set -Eeuo pipefail+ERRtrap,每个 git 步骤都有可读的失败原因;补上REPO_DIR/remote 存在性检查(原来cd失败是静默退出)。run_all.sh:可执行文件缺失时明确报错,单个示例失败不再静默中断整轮,改为收集退出码、结尾打印失败汇总并以非 0 退出。build.sh:检查cmake/nproc是否存在,configure/build 失败给出定位信息。report.sh:原来硬编码/home/luke/00meta/fy/99script/daily_report.py且无任何检查(换机器就静默失败),改为脚本相对路径 + 存在性检查 + 透传参数与退出码。验证:
bash -n与shellcheck全部通过;在临时 repo 上跑通--doctor/--status/--run(含 stash→pull→commit→push→stash pop),并构造失败场景(远端 URL 失效、输出目录不可写、非法--date/--install-cron参数、日志目录不可写)确认都有明确报错和非 0 退出;--install-cron/--uninstall-cron在存在其他 cron 任务时保留了这些任务。Link to Devin session: https://app.devin.ai/sessions/6d4535fd39b04e61afd529b97648b620
Requested by: @AI-1900