Skip to content

Commit d0913df

Browse files
fix: resolve Linear team UUID
1 parent a0699c2 commit d0913df

2 files changed

Lines changed: 31 additions & 5 deletions

File tree

.github/scripts/find-unlinked-cve-issues.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ if [[ -z "${REPOSITORY:-}" ]]; then
2020
exit 1
2121
fi
2222

23+
TEAM_QUERY='query ResolveTeam($teamId: String!) {
24+
team(id: $teamId) { id }
25+
}'
26+
team_payload=$(jq -n \
27+
--arg query "$TEAM_QUERY" \
28+
--arg teamId "$LINEAR_TEAM_ID" \
29+
'{query: $query, variables: {teamId: $teamId}}')
30+
team_response=$(LINEAR_API_KEY="$LINEAR_API_KEY" "$LINEAR_REQUEST" <<<"$team_payload")
31+
32+
if jq -e 'has("errors") or (.data.team.id == null)' >/dev/null <<<"$team_response"; then
33+
echo "Could not resolve LINEAR_TEAM_ID: $(jq -c '.errors // .' <<<"$team_response")" >&2
34+
exit 1
35+
fi
36+
37+
team_uuid=$(jq -r '.data.team.id' <<<"$team_response")
38+
2339
QUERY='query OpenRepositoryCves($teamId: ID!, $titlePrefix: String!, $after: String) {
2440
issues(
2541
first: 100
@@ -50,7 +66,7 @@ all_issues='[]'
5066

5167
while true; do
5268
variables=$(jq -n \
53-
--arg teamId "$LINEAR_TEAM_ID" \
69+
--arg teamId "$team_uuid" \
5470
--arg titlePrefix "$title_prefix" \
5571
--arg after "$after" \
5672
'{

.github/scripts/test-cve-remediation.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ printf '%s\n' "$count" > "$FAKE_CURL_COUNT"
156156
printf '%s' "$payload" > "$FAKE_CURL_PAYLOAD_DIR/$count.json"
157157
158158
if ((count == 1)); then
159+
body='{
160+
"data": {
161+
"team": {"id": "resolved-team-uuid"}
162+
}
163+
}'
164+
elif ((count == 2)); then
159165
body='{
160166
"data": {
161167
"issues": {
@@ -217,7 +223,7 @@ DISCOVERED=$(
217223
FAKE_CURL_COUNT="$FAKE_CURL_COUNT" \
218224
FAKE_CURL_PAYLOAD_DIR="$FAKE_CURL_PAYLOAD_DIR" \
219225
LINEAR_API_KEY="test-key" \
220-
LINEAR_TEAM_ID="team-id" \
226+
LINEAR_TEAM_ID="team-key" \
221227
LINEAR_GRAPHQL_ATTEMPTS=1 \
222228
REPOSITORY="sourcebot-dev/example" \
223229
"$DISCOVERY_SCRIPT"
@@ -243,13 +249,17 @@ EXPECTED_DISCOVERED='[
243249
}
244250
]'
245251
assert_json "paginates Linear results and filters before invoking Claude" "$DISCOVERED" "$EXPECTED_DISCOVERED"
252+
assert_json \
253+
"resolves the configured Linear team identifier" \
254+
"$(jq -c '.variables.teamId' "$FAKE_CURL_PAYLOAD_DIR/1.json")" \
255+
'"team-key"'
246256
assert_json \
247257
"queries Linear with the current repository title prefix" \
248-
"$(jq -c '.variables | {teamId, titlePrefix, after}' "$FAKE_CURL_PAYLOAD_DIR/1.json")" \
249-
'{"teamId":"team-id","titlePrefix":"[sourcebot-dev/example]","after":null}'
258+
"$(jq -c '.variables | {teamId, titlePrefix, after}' "$FAKE_CURL_PAYLOAD_DIR/2.json")" \
259+
'{"teamId":"resolved-team-uuid","titlePrefix":"[sourcebot-dev/example]","after":null}'
250260
assert_json \
251261
"passes the Linear cursor to the next page" \
252-
"$(jq -c '.variables.after' "$FAKE_CURL_PAYLOAD_DIR/2.json")" \
262+
"$(jq -c '.variables.after' "$FAKE_CURL_PAYLOAD_DIR/3.json")" \
253263
'"next-page"'
254264

255265
assert_workflow_contains \

0 commit comments

Comments
 (0)