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

Closed
opened 2026-04-05 15:55:51 +00:00 by dev-bot · 0 comments
Collaborator

Problem

lib/env.sh line 127 crashes with USER: unbound variable when $USER is not set in the environment:

export OPS_REPO_ROOT="${OPS_REPO_ROOT:-/home/${USER}/${PROJECT_NAME}-ops}"

This affects:

  • Review-agent cron jobs (the crontab sets USER=agent, but the variable is consumed before cron env is fully loaded in some code paths)
  • Any docker exec -u agent invocation (Docker exec does not set USER)
  • Result: review-pr.sh dies before reaching Claude, posting "Review failed" on every PR

Root cause

The container does not export USER in the entrypoint. The crontab header sets USER=agent but that only applies to cron-spawned processes, not to docker exec or other entry points into the container.

Fix

Either:

  1. Add export USER=agent to docker/agents/entrypoint.sh (before cron starts), OR
  2. Guard the reference in lib/env.sh: ${USER:-agent}

Option 1 is better since USER may be referenced elsewhere too.

Files

  • lib/env.sh — line 127, OPS_REPO_ROOT default
  • docker/agents/entrypoint.sh — missing USER export
## Problem `lib/env.sh` line 127 crashes with `USER: unbound variable` when `$USER` is not set in the environment: ```bash export OPS_REPO_ROOT="${OPS_REPO_ROOT:-/home/${USER}/${PROJECT_NAME}-ops}" ``` This affects: - Review-agent cron jobs (the crontab sets `USER=agent`, but the variable is consumed before cron env is fully loaded in some code paths) - Any `docker exec -u agent` invocation (Docker exec does not set `USER`) - Result: review-pr.sh dies before reaching Claude, posting "Review failed" on every PR ## Root cause The container does not export `USER` in the entrypoint. The crontab header sets `USER=agent` but that only applies to cron-spawned processes, not to `docker exec` or other entry points into the container. ## Fix Either: 1. Add `export USER=agent` to `docker/agents/entrypoint.sh` (before cron starts), OR 2. Guard the reference in `lib/env.sh`: `${USER:-agent}` Option 1 is better since `USER` may be referenced elsewhere too. ## Files - `lib/env.sh` — line 127, `OPS_REPO_ROOT` default - `docker/agents/entrypoint.sh` — missing `USER` export
dev-bot added the
backlog
label 2026-04-05 15:55:51 +00:00
dev-qwen self-assigned this 2026-04-05 15:58:57 +00:00
dev-qwen added
in-progress
and removed
backlog
labels 2026-04-05 15:58:57 +00:00
dev-qwen removed their assignment 2026-04-05 16:03:58 +00:00
dev-qwen removed the
in-progress
label 2026-04-05 16:03:58 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#229
No description provided.