fix: guard grep in classify.sh pipeline against no-match exit under pipefail
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful

grep exits 1 on no match, which aborts the script under set -euo pipefail.
Wrap with { grep ... || true; } so unknown formulas fall through to default.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude 2026-04-08 19:47:05 +00:00
parent 367b845857
commit 2b9ebe8ac0

View file

@ -36,8 +36,9 @@ if [ -f "$policy_file" ]; then
# Parse: look for `formula_name = "tier"` under [tiers] # Parse: look for `formula_name = "tier"` under [tiers]
# Escape regex metacharacters in formula name for safe grep # Escape regex metacharacters in formula name for safe grep
escaped_formula=$(printf '%s' "$formula" | sed 's/[].[*^$\\]/\\&/g') escaped_formula=$(printf '%s' "$formula" | sed 's/[].[*^$\\]/\\&/g')
# grep may find no match (exit 1); guard with || true to avoid pipefail abort
tier=$(sed -n '/^\[tiers\]/,/^\[/{/^\[tiers\]/d;/^\[/d;p}' "$policy_file" \ tier=$(sed -n '/^\[tiers\]/,/^\[/{/^\[tiers\]/d;/^\[/d;p}' "$policy_file" \
| grep -E "^${escaped_formula}[[:space:]]*=" \ | { grep -E "^${escaped_formula}[[:space:]]*=" || true; } \
| sed -E 's/^[^=]+=[[:space:]]*"([^"]+)".*/\1/' \ | sed -E 's/^[^=]+=[[:space:]]*"([^"]+)".*/\1/' \
| head -n1) | head -n1)