Skip to content

Commit 97626c3

Browse files
committed
fix: retry only Linear queries
1 parent ab64775 commit 97626c3

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

.github/scripts/linear-graphql-request.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,19 @@ if [[ -z "${LINEAR_API_KEY:-}" ]]; then
77
fi
88

99
payload=$(cat)
10-
attempts="${LINEAR_GRAPHQL_ATTEMPTS:-4}"
10+
configured_attempts="${LINEAR_GRAPHQL_ATTEMPTS:-4}"
1111
retry_delay="${LINEAR_GRAPHQL_RETRY_DELAY_SECONDS:-2}"
1212
endpoint="${LINEAR_GRAPHQL_ENDPOINT:-https://api.linear.app/graphql}"
13+
is_mutation=$(jq -r '(.query // "") | test("^\\s*mutation(?:\\s|\\(|\\{)")' <<<"$payload")
14+
15+
# Retrying a mutation after an ambiguous transport failure can replay a write
16+
# that Linear already committed. Queries are safe to retry; mutations fail
17+
# visibly after one attempt and rely on the workflow's reconciliation pass.
18+
if [[ "$is_mutation" == "true" ]]; then
19+
attempts=1
20+
else
21+
attempts="$configured_attempts"
22+
fi
1323

1424
for ((attempt = 1; attempt <= attempts; attempt++)); do
1525
response_file=$(mktemp)

.github/scripts/test-vulnerability-triage.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,21 @@ if [[ "$(<"$FAKE_CURL_COUNT")" != "3" ]]; then
8787
exit 1
8888
fi
8989

90+
printf '0\n' > "$FAKE_CURL_COUNT"
91+
if PATH="$FAKE_CURL_DIR:$PATH" \
92+
FAKE_CURL_COUNT="$FAKE_CURL_COUNT" \
93+
LINEAR_API_KEY="test-key" \
94+
LINEAR_GRAPHQL_ATTEMPTS=3 \
95+
LINEAR_GRAPHQL_RETRY_DELAY_SECONDS=0 \
96+
"$LINEAR_REQUEST" <<<'{"query":"mutation { issueCreate(input: {}) { success } }"}' >/dev/null 2>&1; then
97+
echo "FAIL: ambiguous Linear mutations must not be retried"
98+
exit 1
99+
fi
100+
if [[ "$(<"$FAKE_CURL_COUNT")" != "1" ]]; then
101+
echo "FAIL: expected exactly one Linear mutation attempt"
102+
exit 1
103+
fi
104+
90105
match() {
91106
local finding_id="$1"
92107
jq -c --arg prefix "$PREFIX" --arg findingId "$finding_id" -f "$MATCH_FILTER"

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- Vulnerability triage now keeps Linear issues synchronized with current security findings.
1212

1313
### Fixed
14-
- Fixed vulnerability triage for reusable-workflow callers, repositories without CodeQL, and transient non-JSON Linear API responses. [#1515](https://github.com/sourcebot-dev/sourcebot/pull/1515)
14+
- Fixed vulnerability triage for reusable-workflow callers, repositories without CodeQL, and transient non-JSON Linear query responses. [#1515](https://github.com/sourcebot-dev/sourcebot/pull/1515)
1515

1616
## [5.1.4] - 2026-07-24
1717

0 commit comments

Comments
 (0)