Skip to content

Commit 42c8224

Browse files
msukkariclaude
andcommitted
fix: Dependabot cursor pagination and Linear mutation types
- Dependabot alerts API removed page-based pagination (Oct 2025). Switched to cursor-based pagination using Link header. - Fixed Linear issueCreate mutation: $description and $priority are optional in the schema (String, Int) not required (String!, Int!). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6a47b7b commit 42c8224

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

.github/workflows/trivy-vulnerability-triage.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,23 +245,22 @@ jobs:
245245
fi
246246
247247
ALL_ALERTS="[]"
248-
PAGE=1
248+
URL="https://api.github.com/repos/${{ github.repository }}/dependabot/alerts?state=open&per_page=100"
249249
250-
while true; do
251-
RESPONSE=$(curl -s -w "\n%{http_code}" \
250+
while [ -n "$URL" ]; do
251+
# Fetch with headers saved to parse Link for cursor pagination
252+
HTTP_CODE=$(curl -s -o /tmp/dependabot-body.json -w "%{http_code}" -D /tmp/dependabot-headers.txt \
252253
-H "Accept: application/vnd.github+json" \
253254
-H "Authorization: Bearer $DEPENDABOT_PAT" \
254-
"https://api.github.com/repos/${{ github.repository }}/dependabot/alerts?state=open&per_page=100&page=$PAGE")
255-
256-
HTTP_CODE=$(echo "$RESPONSE" | tail -1)
257-
BODY=$(echo "$RESPONSE" | sed '$d')
255+
"$URL")
258256
259257
if [ "$HTTP_CODE" != "200" ]; then
260258
echo "::warning::Failed to fetch Dependabot alerts (HTTP $HTTP_CODE). Writing empty results."
261259
echo "[]" > dependabot-alerts.json
262260
exit 0
263261
fi
264262
263+
BODY=$(cat /tmp/dependabot-body.json)
265264
COUNT=$(echo "$BODY" | jq 'length')
266265
if [ "$COUNT" -eq 0 ]; then
267266
break
@@ -283,10 +282,8 @@ jobs:
283282
284283
ALL_ALERTS=$(echo "$ALL_ALERTS" "$EXTRACTED" | jq -s '.[0] + .[1]')
285284
286-
if [ "$COUNT" -lt 100 ]; then
287-
break
288-
fi
289-
PAGE=$((PAGE + 1))
285+
# Parse Link header for next page URL (cursor-based pagination)
286+
URL=$(sed -n 's/.*<\([^>]*\)>; *rel="next".*/\1/p' /tmp/dependabot-headers.txt || true)
290287
done
291288
292289
ALERT_COUNT=$(echo "$ALL_ALERTS" | jq 'length')
@@ -537,7 +534,7 @@ jobs:
537534
# Write CVEs to temp file so the while loop doesn't run in a pipe subshell
538535
echo "$STRUCTURED_OUTPUT" | jq -c '.cves[]' > /tmp/cves.jsonl
539536
540-
MUTATION='mutation CreateIssue($teamId: String!, $title: String!, $description: String!, $priority: Int!, $labelIds: [String!], $stateId: String) { issueCreate(input: { teamId: $teamId, title: $title, description: $description, priority: $priority, labelIds: $labelIds, stateId: $stateId }) { success issue { id identifier url } } }'
537+
MUTATION='mutation CreateIssue($teamId: String!, $title: String!, $description: String, $priority: Int, $labelIds: [String!], $stateId: String) { issueCreate(input: { teamId: $teamId, title: $title, description: $description, priority: $priority, labelIds: $labelIds, stateId: $stateId }) { success issue { id identifier url } } }'
541538
542539
while IFS= read -r cve; do
543540
CVE_ID=$(echo "$cve" | jq -r '.cveId')

0 commit comments

Comments
 (0)