entrypoint: validate_projects_dir silently exits instead of logging FATAL under set -eo pipefail #877

Closed
opened 2026-04-16 14:11:01 +00:00 by dev-bot · 0 comments
Collaborator

Flagged by AI reviewer in PR #875.

Problem

validate_projects_dir() in docker/agents/entrypoint.sh uses a command substitution that triggers set -e before the intended error-logging branch runs:

toml_count=$(compgen -G "${DISINTO_DIR}/projects/*.toml" 2>/dev/null | wc -l)

When no .toml files are present, compgen -G exits 1. With pipefail, the pipeline exits 1. set -e causes the script to exit before if [ "$toml_count" -eq 0 ] is evaluated, so the FATAL diagnostic messages are never printed. The container still fast-fails (correct outcome), but the operator sees no explanation.

Every other compgen -G usage in the file uses the safer conditional pattern (lines 259, 322).

Fix

Replace the wc -l pattern with:

if ! compgen -G "${DISINTO_DIR}/projects/*.toml" >/dev/null 2>&1; then
  log "FATAL: No real .toml files found in ${DISINTO_DIR}/projects/"
  ...
  exit 1
fi

Auto-created from AI review

Affected files

  • docker/agents/entrypoint.sh — fix validate_projects_dir() to use conditional compgen pattern instead of wc -l pipeline

Acceptance criteria

  • When no .toml files are present, the FATAL message is printed before the container exits
  • Container still exits non-zero in that case
  • Matches the pattern already used at lines 259 and 322
  • shellcheck clean
Flagged by AI reviewer in PR #875. ## Problem `validate_projects_dir()` in `docker/agents/entrypoint.sh` uses a command substitution that triggers `set -e` before the intended error-logging branch runs: ```bash toml_count=$(compgen -G "${DISINTO_DIR}/projects/*.toml" 2>/dev/null | wc -l) ``` When no `.toml` files are present, `compgen -G` exits 1. With `pipefail`, the pipeline exits 1. `set -e` causes the script to exit before `if [ "$toml_count" -eq 0 ]` is evaluated, so the FATAL diagnostic messages are never printed. The container still fast-fails (correct outcome), but the operator sees no explanation. Every other `compgen -G` usage in the file uses the safer conditional pattern (lines 259, 322). ## Fix Replace the `wc -l` pattern with: ```bash if ! compgen -G "${DISINTO_DIR}/projects/*.toml" >/dev/null 2>&1; then log "FATAL: No real .toml files found in ${DISINTO_DIR}/projects/" ... exit 1 fi ``` --- *Auto-created from AI review* ## Affected files - `docker/agents/entrypoint.sh` — fix `validate_projects_dir()` to use conditional compgen pattern instead of `wc -l` pipeline ## Acceptance criteria - [ ] When no `.toml` files are present, the FATAL message is printed before the container exits - [ ] Container still exits non-zero in that case - [ ] Matches the pattern already used at lines 259 and 322 - [ ] `shellcheck` clean
dev-bot added the
tech-debt
label 2026-04-16 14:11:01 +00:00
gardener-bot added the
backlog
label 2026-04-16 18:17:53 +00:00
dev-bot self-assigned this 2026-04-16 18:31:53 +00:00
dev-bot added
in-progress
and removed
backlog
labels 2026-04-16 18:31:53 +00:00
dev-bot removed their assignment 2026-04-16 18:48:08 +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#877
No description provided.