Harden gen-djmix, gen-vgm, strip-mb-tags, notify-telegram under set -euo pipefail (R1)
Adds strict mode to four maintenance scripts, with guards so expected non-zero exits (empty beet queries, a missing config, a curl timeout) log/skip instead of aborting: gen-djmix bails cleanly if djmix-albums.txt is absent and tolerates a bad single query; gen-vgm tolerates an empty query; strip-mb-tags quotes its path arg and best-efforts the trailing beet update; notify-telegram guards curl so a network error still reaches its explicit "send failed" branch. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
# Telegram messages are capped at 4096 chars. Anything longer is truncated
|
||||
# with a "...<truncated>" tail. Returns exit 0 on send-OK, non-zero otherwise.
|
||||
|
||||
set -u
|
||||
set -euo pipefail
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
CONFIG="${ALEMBIC_CONFIG_DIR:-/config}/pipeline/telegram/notify.env"
|
||||
@@ -42,11 +42,13 @@ print(s, end='')
|
||||
|
||||
# Send via Bot API. Disable web-page preview and use plain text (no parse_mode)
|
||||
# so log content with special chars doesn't get interpreted as Markdown.
|
||||
# `|| true`: a curl timeout/network error must fall through to the explicit
|
||||
# ok-check below (which reports "send failed" and exits 2), not abort here.
|
||||
resp=$(curl -s --max-time 15 -X POST \
|
||||
"https://api.telegram.org/bot${TG_BOT_TOKEN}/sendMessage" \
|
||||
--data-urlencode "chat_id=${TG_CHAT_ID}" \
|
||||
--data-urlencode "text=${MSG}" \
|
||||
--data-urlencode "disable_web_page_preview=true")
|
||||
--data-urlencode "disable_web_page_preview=true" || true)
|
||||
|
||||
ok=$(echo "$resp" | python3 -c "import sys,json;print(json.load(sys.stdin).get('ok',False))" 2>/dev/null || echo False)
|
||||
if [[ "$ok" != "True" ]]; then
|
||||
|
||||
Reference in New Issue
Block a user