Compare commits

...

3 commits

Author SHA1 Message Date
Agent
96870d9f30 fix: fix: vault_request RETURN trap fires prematurely when vault-env.sh is sourced (#773)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
ci/woodpecker/pr/secret-scan Pipeline was successful
2026-04-16 19:02:47 +00:00
c77fb1dc53 Merge pull request 'fix: entrypoint: validate_projects_dir silently exits instead of logging FATAL under set -eo pipefail (#877)' (#905) from fix/issue-877 into main
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
2026-04-16 18:48:07 +00:00
Claude
bbaccd678d fix: entrypoint: validate_projects_dir silently exits instead of logging FATAL under set -eo pipefail (#877)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
`compgen -G ... | wc -l` under `set -eo pipefail` aborts the script on
the non-zero pipeline exit (compgen returns 1 on no match) before the
FATAL diagnostic branch can run. The container still fast-fails, but
operators saw no explanation.

Switch to the conditional `if ! compgen -G ... >/dev/null 2>&1; then`
pattern already used at the two other compgen call sites in this file
(bootstrap_factory_repo and the PROJECT_NAME parser). The count for the
success-path log is computed after we've confirmed at least one match.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 18:36:42 +00:00
2 changed files with 12 additions and 4 deletions

View file

@ -346,15 +346,19 @@ bootstrap_factory_repo
# This prevents the silent-zombie mode where the polling loop matches zero files # This prevents the silent-zombie mode where the polling loop matches zero files
# and does nothing forever. # and does nothing forever.
validate_projects_dir() { validate_projects_dir() {
local toml_count # NOTE: compgen -G exits non-zero when no matches exist, so piping it through
toml_count=$(compgen -G "${DISINTO_DIR}/projects/*.toml" 2>/dev/null | wc -l) # `wc -l` under `set -eo pipefail` aborts the script before the FATAL branch
if [ "$toml_count" -eq 0 ]; then # can log a diagnostic (#877). Use the conditional form already adopted at
# lines above (see bootstrap_factory_repo, PROJECT_NAME parsing).
if ! compgen -G "${DISINTO_DIR}/projects/*.toml" >/dev/null 2>&1; then
log "FATAL: No real .toml files found in ${DISINTO_DIR}/projects/" log "FATAL: No real .toml files found in ${DISINTO_DIR}/projects/"
log "Expected at least one project config file (e.g., disinto.toml)" log "Expected at least one project config file (e.g., disinto.toml)"
log "The directory only contains *.toml.example template files." log "The directory only contains *.toml.example template files."
log "Mount the host ./projects volume or copy real .toml files into the container." log "Mount the host ./projects volume or copy real .toml files into the container."
exit 1 exit 1
fi fi
local toml_count
toml_count=$(compgen -G "${DISINTO_DIR}/projects/*.toml" | wc -l)
log "Projects directory validated: ${toml_count} real .toml file(s) found" log "Projects directory validated: ${toml_count} real .toml file(s) found"
} }

View file

@ -128,7 +128,6 @@ vault_request() {
# Validate TOML content # Validate TOML content
local tmp_toml local tmp_toml
tmp_toml=$(mktemp /tmp/vault-XXXXXX.toml) tmp_toml=$(mktemp /tmp/vault-XXXXXX.toml)
trap 'rm -f "$tmp_toml"' RETURN
printf '%s' "$toml_content" > "$tmp_toml" printf '%s' "$toml_content" > "$tmp_toml"
@ -136,6 +135,7 @@ vault_request() {
local vault_env="${FACTORY_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}/action-vault/vault-env.sh" local vault_env="${FACTORY_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}/action-vault/vault-env.sh"
if [ ! -f "$vault_env" ]; then if [ ! -f "$vault_env" ]; then
echo "ERROR: vault-env.sh not found at $vault_env" >&2 echo "ERROR: vault-env.sh not found at $vault_env" >&2
rm -f "$tmp_toml"
return 1 return 1
fi fi
@ -145,11 +145,15 @@ vault_request() {
if ! source "$vault_env"; then if ! source "$vault_env"; then
FORGE_TOKEN="${_saved_forge_token:-}" FORGE_TOKEN="${_saved_forge_token:-}"
echo "ERROR: failed to source vault-env.sh" >&2 echo "ERROR: failed to source vault-env.sh" >&2
rm -f "$tmp_toml"
return 1 return 1
fi fi
# Restore caller's FORGE_TOKEN after validation # Restore caller's FORGE_TOKEN after validation
FORGE_TOKEN="${_saved_forge_token:-}" FORGE_TOKEN="${_saved_forge_token:-}"
# Set trap AFTER sourcing vault-env.sh to avoid RETURN trap firing during source
trap 'rm -f "$tmp_toml"' RETURN
# Run validation # Run validation
if ! validate_vault_action "$tmp_toml"; then if ! validate_vault_action "$tmp_toml"; then
echo "ERROR: TOML validation failed" >&2 echo "ERROR: TOML validation failed" >&2