actualbudget / actualbudget/actual

[Bug]: check-on-stop agent hook reports bogus typecheck/test failures when yarn is not on the hook PATH

未关闭
#8,465 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
28.7k
派生
3k
平均合并
2 天 11 小时
30 天内合并 PR
65

描述

🤖 _Found while an AI agent was working in this repo; fix PR incoming from the same session._

### What happened?

`scripts/agent-hooks/check-on-stop.sh` (the Stop hook added in #8089 that runs typecheck + tests for touched workspaces) assumes `yarn` is on `PATH`. Agent hook processes often run with a minimal environment that lacks the nvm/corepack shims, so every `yarn workspace run …` invocation fails with:

```
Stop check found failures in touched workspaces:
[typecheck failed: @actual-app/core]
scripts/agent-hooks/check-on-stop.sh: line 83: yarn: command not found
[tests failed: @actual-app/core]
scripts/agent-hooks/check-on-stop.sh: line 89: yarn: command not found
```

Two problems:

1. The checks never actually run, so the hook provides no protection in these environments.
2. Worse, the failure is reported to the agent as a _typecheck/test failure_ (exit 2), sending it off to "fix" failures that don't exist. The other hooks (e.g. `format-edited-file.sh`) skip gracefully when their tools are missing; this one reports a bogus failure instead.

### How can we reproduce the issue?

1. In a repo checkout where yarn is provided via nvm + corepack (no global yarn on a minimal PATH):
2. Touch a source file in any workspace (e.g. add an untracked `.ts` file under `packages/loot-core/src/`).
3. Run the hook with a scrubbed environment:

```sh
echo '{}' | env -i HOME="$HOME" PATH=/usr/bin:/bin:/usr/sbin:/sbin \
bash scripts/agent-hooks/check-on-stop.sh; echo "exit: $?"
```

4. Expected: the hook either runs the checks (finding yarn via the repo's `.nvmrc` toolchain) or skips quietly.
Actual: exit 2 with `[typecheck failed: …] yarn: command not found`, misreported as a check failure.

### Where are you hosting Actual?

Locally via Yarn

### Operating System

Mac OSX

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。