EC-21: FIX: 422 Unprocessable Entity for PR Management Workflow
This commit is contained in:
@@ -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"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user