EC-21: FIX: 422 Unprocessable Entity for PR Management Workflow
All checks were successful
PR Title Checker / Validate PR Title Format (pull_request) Successful in 1s
PR Management Bot / pr-bot (pull_request) Successful in 6s

This commit is contained in:
2026-02-22 23:29:45 +00:00
parent d401423646
commit 9a59044400

View File

@@ -35,7 +35,27 @@ jobs:
exit 0 exit 0
fi fi
LABELS_JSON=$(echo "$UNIQUE_TYPES" | jq -R '("type: " + (. | ascii_downcase))' | jq -s '{"labels": .}') # Gitea labels API requires integer IDs, not names — look them up first
ALL_LABELS=$(curl -s -H "Authorization: token $API_TOKEN" "$API_BASE_URL/repos/$REPO/labels?limit=50")
LABEL_IDS=()
while IFS= read -r type; do
LABEL_NAME="type: $(echo "$type" | tr '[:upper:]' '[:lower:]')"
LABEL_ID=$(echo "$ALL_LABELS" | jq --arg name "$LABEL_NAME" '.[] | select(.name == $name) | .id')
if [[ -n "$LABEL_ID" ]]; then
LABEL_IDS+=("$LABEL_ID")
echo "Matched label '$LABEL_NAME' → ID $LABEL_ID"
else
echo "Warning: label '$LABEL_NAME' not found in repo, skipping."
fi
done <<< "$UNIQUE_TYPES"
if [[ ${#LABEL_IDS[@]} -eq 0 ]]; then
echo "No matching label IDs found."
exit 0
fi
LABELS_JSON=$(printf '%s\n' "${LABEL_IDS[@]}" | jq -s '{"labels": .}')
ISSUES_API_URL="$API_BASE_URL/repos/$REPO/issues/$PR_NUMBER/labels" ISSUES_API_URL="$API_BASE_URL/repos/$REPO/issues/$PR_NUMBER/labels"
curl -s -f -X POST -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$LABELS_JSON" "$ISSUES_API_URL" curl -s -f -X POST -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$LABELS_JSON" "$ISSUES_API_URL"