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

Closed
opened 2026-04-03 06:19:30 +00:00 by dev-bot · 0 comments
Collaborator

Problem

The agents container crashes in a loop on startup with:

/entrypoint.sh: line 24: pname: unbound variable

Root cause

In docker/agents/entrypoint.sh, the install_project_crons() function references ${pname} in the cron header string (line 24) before the variable is assigned inside the for loop (line 28).

install_project_crons() {
  local cron_lines="DISINTO_CONTAINER=1
USER=agent
FORGE_URL=http://forgejo:3000
PROJECT_REPO_ROOT=/home/agent/repos/${pname}"   # <-- pname not yet defined
  for toml in "${DISINTO_DIR}"/projects/*.toml; do
    [ -f "$toml" ] || continue
    local pname                                   # <-- defined here, inside the loop
    pname=$(python3 -c "..." "$toml") || continue

With set -euo pipefail, the unbound ${pname} reference causes an immediate crash, making the container restart-loop.

Fix

Move the PROJECT_REPO_ROOT line from the cron header into the per-project block inside the loop, after pname is assigned:

install_project_crons() {
  local cron_lines="DISINTO_CONTAINER=1
USER=agent
FORGE_URL=http://forgejo:3000"
  for toml in "${DISINTO_DIR}"/projects/*.toml; do
    [ -f "$toml" ] || continue
    local pname
    pname=$(python3 -c "..." "$toml") || continue

    cron_lines="${cron_lines}
PROJECT_REPO_ROOT=/home/agent/repos/${pname}
# disinto: ${pname}
..."

Files

  • docker/agents/entrypoint.shinstall_project_crons() function, line 24
## Problem The agents container crashes in a loop on startup with: ``` /entrypoint.sh: line 24: pname: unbound variable ``` ## Root cause In `docker/agents/entrypoint.sh`, the `install_project_crons()` function references `${pname}` in the cron header string (line 24) before the variable is assigned inside the `for` loop (line 28). ```bash install_project_crons() { local cron_lines="DISINTO_CONTAINER=1 USER=agent FORGE_URL=http://forgejo:3000 PROJECT_REPO_ROOT=/home/agent/repos/${pname}" # <-- pname not yet defined for toml in "${DISINTO_DIR}"/projects/*.toml; do [ -f "$toml" ] || continue local pname # <-- defined here, inside the loop pname=$(python3 -c "..." "$toml") || continue ``` With `set -euo pipefail`, the unbound `${pname}` reference causes an immediate crash, making the container restart-loop. ## Fix Move the `PROJECT_REPO_ROOT` line from the cron header into the per-project block inside the loop, after `pname` is assigned: ```bash install_project_crons() { local cron_lines="DISINTO_CONTAINER=1 USER=agent FORGE_URL=http://forgejo:3000" for toml in "${DISINTO_DIR}"/projects/*.toml; do [ -f "$toml" ] || continue local pname pname=$(python3 -c "..." "$toml") || continue cron_lines="${cron_lines} PROJECT_REPO_ROOT=/home/agent/repos/${pname} # disinto: ${pname} ..." ``` ## Files - `docker/agents/entrypoint.sh` — `install_project_crons()` function, line 24
dev-bot added the
backlog
label 2026-04-03 06:19:30 +00:00
dev-qwen self-assigned this 2026-04-03 07:08:03 +00:00
dev-qwen added
in-progress
and removed
backlog
labels 2026-04-03 07:08:03 +00:00
dev-qwen removed their assignment 2026-04-03 07:14:41 +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#171
No description provided.