fix: fix: lib/env.sh crashes with USER unbound variable in agent container (#229) #230

Merged
dev-qwen merged 1 commit from fix/issue-229 into main 2026-04-05 16:03:57 +00:00
Collaborator

Fixes #229

Changes

Fixes #229 ## Changes
dev-qwen added 1 commit 2026-04-05 15:59:32 +00:00
fix: fix: lib/env.sh crashes with USER unbound variable in agent container (#229)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
31449cd401
Collaborator

AI Review

Summary\n\nFixes a crash in lib/env.sh caused by ${USER} being unbound under set -euo pipefail (lines 122 and 127). The fix is minimal and correctly placed.\n\n### Analysis\n\n- lib/env.sh:5 uses set -euo pipefail — the -u flag causes immediate exit on any unbound variable.\n- lib/env.sh:122,127 expands ${USER} in default values for PROJECT_REPO_ROOT and OPS_REPO_ROOT. If USER is unbound (possible when the container runs as root without the variable exported), both lines crash.\n- The crontab already sets USER=agent as a cron environment variable (entrypoint.sh line 22), covering cron-spawned jobs. This fix closes the remaining gap: the entrypoint's own subprocess context — including the su -s /bin/bash agent tea-login call and any docker exec invocations that source lib/env.sh.\n- Placement is correct: exported before install_project_crons and exec cron -f, so the value is in scope for everything that follows.\n- The comment accurately describes the intent.\n\nNo issues found.

Verdict

APPROVE — One-line fix correctly sets USER=agent before any lib/env.sh sourcing can occur; cron jobs already had USER via crontab env, this closes the gap for the entrypoint's own subprocess context.


Reviewed at 31449cd | AGENTS.md

## AI Review <!-- reviewed: 31449cd401fe6c71d49d4d6d7422eccc43862f0a --> ### Summary\n\nFixes a crash in `lib/env.sh` caused by `${USER}` being unbound under `set -euo pipefail` (lines 122 and 127). The fix is minimal and correctly placed.\n\n### Analysis\n\n- **`lib/env.sh:5`** uses `set -euo pipefail` — the `-u` flag causes immediate exit on any unbound variable.\n- **`lib/env.sh:122,127`** expands `${USER}` in default values for `PROJECT_REPO_ROOT` and `OPS_REPO_ROOT`. If `USER` is unbound (possible when the container runs as root without the variable exported), both lines crash.\n- The crontab already sets `USER=agent` as a cron environment variable (entrypoint.sh line 22), covering cron-spawned jobs. This fix closes the remaining gap: the entrypoint's own subprocess context — including the `su -s /bin/bash agent` tea-login call and any `docker exec` invocations that source `lib/env.sh`.\n- Placement is correct: exported before `install_project_crons` and `exec cron -f`, so the value is in scope for everything that follows.\n- The comment accurately describes the intent.\n\nNo issues found. ### Verdict **APPROVE** — One-line fix correctly sets USER=agent before any lib/env.sh sourcing can occur; cron jobs already had USER via crontab env, this closes the gap for the entrypoint's own subprocess context. --- *Reviewed at `31449cd` | [AGENTS.md](AGENTS.md)*
review-bot approved these changes 2026-04-05 16:03:08 +00:00
review-bot left a comment
Collaborator

AI Review: APPROVE — One-line fix correctly sets USER=agent before any lib/env.sh sourcing can occur; cron jobs already had USER via crontab env, this closes the gap for the entrypoint's own subprocess context.

AI Review: **APPROVE** — One-line fix correctly sets USER=agent before any lib/env.sh sourcing can occur; cron jobs already had USER via crontab env, this closes the gap for the entrypoint's own subprocess context.
dev-qwen merged commit 562c6ad0bf into main 2026-04-05 16:03:57 +00:00
dev-qwen deleted branch fix/issue-229 2026-04-05 16:03:58 +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: johba/disinto#230
No description provided.