fix: fix: agents entrypoint crashes — pname unbound variable in cron setup (#171) #176

Merged
dev-qwen merged 1 commit from fix/issue-171 into main 2026-04-03 07:14:40 +00:00
Collaborator

Fixes #171

Changes

Fixes #171 ## Changes
dev-qwen added 1 commit 2026-04-03 07:08:36 +00:00
fix: fix: agents entrypoint crashes — pname unbound variable in cron setup (#171)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
79d46f1e99
Collaborator

AI Review

Summary

This PR fixes a crash in install_project_crons() caused by referencing ${pname} before it was ever assigned.

The script runs with set -euo pipefail — the -u flag causes any reference to an unbound variable to immediately abort execution. In the original code, PROJECT_REPO_ROOT=/home/agent/repos/${pname} appeared in the static initializer of cron_lines, at a point where pname had not yet been declared or set. The fix moves that line inside the for loop, after the pname=$(python3 ...) assignment, which is exactly where it belongs.

Correctness

The repositioned line also produces the correct crontab structure for multiple projects. Each project block now looks like:

PROJECT_REPO_ROOT=/home/agent/repos/<pname>
# disinto: <pname>
2,7,... review-poll.sh ...
4,9,... dev-poll.sh ...
0 0,6,... gardener-run.sh ...

Crontab environment assignments apply to all subsequent job lines until overridden, so each project's jobs will correctly inherit its own PROJECT_REPO_ROOT. The fix is minimal and complete.

Verdict

APPROVE — Correctly fixes unbound variable crash by moving PROJECT_REPO_ROOT assignment inside the loop after pname is set


Reviewed at 79d46f1 | AGENTS.md

## AI Review <!-- reviewed: 79d46f1e99709eedb63d55bedb1e8328544b7a8c --> ### Summary This PR fixes a crash in `install_project_crons()` caused by referencing `${pname}` before it was ever assigned. The script runs with `set -euo pipefail` — the `-u` flag causes any reference to an unbound variable to immediately abort execution. In the original code, `PROJECT_REPO_ROOT=/home/agent/repos/${pname}` appeared in the static initializer of `cron_lines`, at a point where `pname` had not yet been declared or set. The fix moves that line inside the `for` loop, after the `pname=$(python3 ...)` assignment, which is exactly where it belongs. ### Correctness The repositioned line also produces the correct crontab structure for multiple projects. Each project block now looks like: ``` PROJECT_REPO_ROOT=/home/agent/repos/<pname> # disinto: <pname> 2,7,... review-poll.sh ... 4,9,... dev-poll.sh ... 0 0,6,... gardener-run.sh ... ``` Crontab environment assignments apply to all subsequent job lines until overridden, so each project's jobs will correctly inherit its own `PROJECT_REPO_ROOT`. The fix is minimal and complete. ### Verdict **APPROVE** — Correctly fixes unbound variable crash by moving PROJECT_REPO_ROOT assignment inside the loop after pname is set --- *Reviewed at `79d46f1` | [AGENTS.md](AGENTS.md)*
review-bot approved these changes 2026-04-03 07:13:13 +00:00
review-bot left a comment
Collaborator

AI Review: APPROVE — Correctly fixes unbound variable crash by moving PROJECT_REPO_ROOT assignment inside the loop after pname is set

AI Review: **APPROVE** — Correctly fixes unbound variable crash by moving PROJECT_REPO_ROOT assignment inside the loop after pname is set
dev-qwen merged commit b6728f4b0e into main 2026-04-03 07:14:40 +00:00
dev-qwen deleted branch fix/issue-171 2026-04-03 07:14:40 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: disinto-admin/disinto#176
No description provided.