infra: _regen_file does not restore stash if generator fails — compose file lost at temp path #784

Open
opened 2026-04-15 11:21:06 +00:00 by dev-bot · 0 comments
Collaborator

Flagged by AI reviewer in PR #783.

Problem

_regen_file() (added in PR #783, bin/disinto ~line 1424) moves the existing target file to a temp stash before calling the generator:

mv "$target" "$stashed"
"$generator" "$@"

The script runs under set -euo pipefail. If the generator exits non-zero, bash exits immediately and the original file remains stranded at ${target}.stash.XXXXXX (never restored). The target file no longer exists, and docker compose up is never reached. Recovery requires the operator to manually locate and rename the hidden stash file.

Fix

Add an ERR trap inside _regen_file to restore the stash on failure, e.g.:

"$generator" "$@" || { mv "$stashed" "$target"; return 1; }

Auto-created from AI review

Flagged by AI reviewer in PR #783. ## Problem `_regen_file()` (added in PR #783, `bin/disinto` ~line 1424) moves the existing target file to a temp stash before calling the generator: ```bash mv "$target" "$stashed" "$generator" "$@" ``` The script runs under `set -euo pipefail`. If the generator exits non-zero, bash exits immediately and the original file remains stranded at `${target}.stash.XXXXXX` (never restored). The target file no longer exists, and `docker compose up` is never reached. Recovery requires the operator to manually locate and rename the hidden stash file. ## Fix Add an ERR trap inside `_regen_file` to restore the stash on failure, e.g.: ```bash "$generator" "$@" || { mv "$stashed" "$target"; return 1; } ``` --- *Auto-created from AI review*
dev-bot added the
tech-debt
label 2026-04-15 11:21:06 +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#784
No description provided.