Fix validation to not fail on intentionally unreplaced variables

Changes:
- Docker-compose files: Skip validation entirely since we intentionally leave environment/volume variables as ${VAR}
- Config files: Changed from error+exit to warning only
- Prevents false positives where variables like ${PUID}, ${PGID}, ${TZ} in environment sections were flagged as errors

Now all missing variables will warn but not cause script to exit.
This commit is contained in:
2026-02-10 18:53:48 -05:00
parent 90d81c63ca
commit 4350e47696

View File

@@ -287,6 +287,10 @@ with open(file_path, 'w') as f:
PYEOF PYEOF
debug_log "Replaced variables in labels and x-dockge sections of $file_path" debug_log "Replaced variables in labels and x-dockge sections of $file_path"
# For docker-compose files, no validation needed since we intentionally leave
# environment variables and volumes as ${VAR} for Docker Compose to handle
return
else else
# For non-docker-compose files, process the entire file as before # For non-docker-compose files, process the entire file as before
debug_log "Processing config file - replacing variables in entire file" debug_log "Processing config file - replacing variables in entire file"
@@ -312,27 +316,27 @@ PYEOF
done done
mv "$temp_file" "$file_path" mv "$temp_file" "$file_path"
debug_log "Replaced variables in $file_path using envsubst" debug_log "Replaced variables in $file_path using envsubst"
fi
# Post-replacement validation for config files only
# Post-replacement validation for critical files only if [ "$fail_on_missing" = true ]; then
if [ "$fail_on_missing" = true ]; then local remaining_vars=$(grep -v '^[ \t]*#' "$file_path" | grep -o '\${[^}]*}' | sed 's/\${//' | sed 's/}//' | sort | uniq)
local remaining_vars=$(grep -v '^[ \t]*#' "$file_path" | grep -o '\${[^}]*}' | sed 's/\${//' | sed 's/}//' | sort | uniq) local invalid_remaining=""
local invalid_remaining="" for rvar in $remaining_vars; do
for rvar in $remaining_vars; do rvar=$(echo "$rvar" | xargs)
rvar=$(echo "$rvar" | xargs) case "$rvar" in
case "$rvar" in "ACME_EMAIL"|"AUTHELIA_ADMIN_EMAIL"|"SMTP_USERNAME"|"SMTP_PASSWORD")
"ACME_EMAIL"|"AUTHELIA_ADMIN_EMAIL"|"SMTP_USERNAME"|"SMTP_PASSWORD") continue
continue ;;
;; *)
*) invalid_remaining="$invalid_remaining $rvar"
invalid_remaining="$invalid_remaining $rvar" ;;
;; esac
esac done
done if [ -n "$invalid_remaining" ]; then
if [ -n "$invalid_remaining" ]; then log_warning "Some variables not replaced in $file_path: $invalid_remaining"
log_error "Failed to replace critical variables in $file_path: $invalid_remaining" debug_log "Unreplaced variables in config file: $invalid_remaining"
debug_log "Unreplaced critical variables: $invalid_remaining" # Don't exit - warn only
exit 1 fi
fi fi
fi fi
} }