Skip to content

Commit d29435b

Browse files
authored
Fix fuzzer automation issues (#10693)
Fuzzer automation used wrong artifact ids for reproduction and didn't correctly set up oidc environment Signed-off-by: Robert Kruszewski <[email protected]>
1 parent 31027fc commit d29435b

2 files changed

Lines changed: 71 additions & 27 deletions

File tree

‎.github/scripts/close_fixed_fuzzer_issues.py‎

Lines changed: 60 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import subprocess
1616
import sys
1717
import tempfile
18+
import zipfile
1819
from dataclasses import dataclass
1920

2021
CLEANUP_MARKER = "Auto-checked by weekly fuzzer issue cleanup"
@@ -90,6 +91,57 @@ def extract_run_id(artifact_url: str) -> str | None:
9091
return match.group(1) if match else None
9192

9293

94+
def extract_artifact_id(artifact_url: str) -> str | None:
95+
"""Extract the artifact ID from an artifact URL like .../artifacts/67890."""
96+
match = re.search(r"artifacts/(\d+)", artifact_url)
97+
return match.group(1) if match else None
98+
99+
100+
def download_artifact(
101+
repo: str, run_id: str, artifact_id: str | None, artifact_name: str, dest: str
102+
) -> str | None:
103+
"""Download the crash artifact into dest. Returns an error message on failure.
104+
105+
Download by artifact ID when the URL has one. A re-run of the fuzz workflow uploads a second
106+
artifact with the same name, and `gh run download --name` then gets the artifact of the
107+
latest attempt, which does not contain the crash file of the issue.
108+
"""
109+
if not artifact_id:
110+
result = run(
111+
[
112+
"gh",
113+
"run",
114+
"download",
115+
run_id,
116+
"--name",
117+
artifact_name,
118+
"--repo",
119+
repo,
120+
"--dir",
121+
dest,
122+
],
123+
capture_output=True,
124+
text=True,
125+
)
126+
return result.stderr.strip() if result.returncode != 0 else None
127+
128+
zip_path = os.path.join(dest, "artifact.zip")
129+
with open(zip_path, "wb") as zip_file:
130+
result = run(
131+
["gh", "api", f"repos/{repo}/actions/artifacts/{artifact_id}/zip"],
132+
stdout=zip_file,
133+
stderr=subprocess.PIPE,
134+
text=True,
135+
)
136+
if result.returncode != 0:
137+
return result.stderr.strip()
138+
139+
with zipfile.ZipFile(zip_path) as archive:
140+
archive.extractall(dest)
141+
os.remove(zip_path)
142+
return None
143+
144+
93145
def has_cleanup_comment(repo: str, issue_number: int) -> bool:
94146
"""Check if the issue already has an 'Artifact Unavailable' cleanup comment."""
95147
result = run(
@@ -281,26 +333,16 @@ def main() -> None:
281333

282334
# Download artifact into a temp directory
283335
with tempfile.TemporaryDirectory() as tmpdir:
284-
artifact_name = f"{args.target}-crash-artifacts"
285-
dl_result = run(
286-
[
287-
"gh",
288-
"run",
289-
"download",
290-
run_id,
291-
"--name",
292-
artifact_name,
293-
"--repo",
294-
args.repo,
295-
"--dir",
296-
tmpdir,
297-
],
298-
capture_output=True,
299-
text=True,
336+
dl_error = download_artifact(
337+
args.repo,
338+
run_id,
339+
extract_artifact_id(issue.artifact_url),
340+
f"{args.target}-crash-artifacts",
341+
tmpdir,
300342
)
301343

302-
if dl_result.returncode != 0:
303-
print(f" Artifact download failed: {dl_result.stderr.strip()}")
344+
if dl_error is not None:
345+
print(f" Artifact download failed: {dl_error}")
304346
if not has_cleanup_comment(args.repo, issue.number):
305347
close_artifact_unavailable(args.repo, issue.number, args.dry_run)
306348
else:

‎.github/workflows/fuzzer-fix-automation.yml‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,14 @@ jobs:
161161
RUN_ID=$(echo "$ARTIFACT_URL" | grep -oP 'runs/\K[0-9]+')
162162
ARTIFACT_ID=$(echo "$ARTIFACT_URL" | grep -oP 'artifacts/\K[0-9]+')
163163
164-
# Artifact name matches run-fuzzer.yml upload: ${{ inputs.fuzz_target }}-crash-artifacts
165-
TARGET="${{ steps.extract.outputs.target }}"
166-
ARTIFACT_NAME="${TARGET}-crash-artifacts"
164+
echo "Downloading artifact $ARTIFACT_ID from run $RUN_ID"
167165
168-
echo "Downloading artifact $ARTIFACT_NAME (ID: $ARTIFACT_ID) from run $RUN_ID"
169-
170-
# Download the artifact
171-
gh run download "$RUN_ID" --name "$ARTIFACT_NAME" --repo ${{ github.repository }}
166+
# Download by artifact ID, not by name. A re-run of the fuzz workflow uploads a
167+
# second artifact with the same name, and `gh run download --name` then gets the
168+
# artifact of the latest attempt, which does not contain this crash file.
169+
gh api "repos/${{ github.repository }}/actions/artifacts/$ARTIFACT_ID/zip" > crash-artifact.zip
170+
unzip -q crash-artifact.zip
171+
rm crash-artifact.zip
172172
173173
# Verify crash file exists
174174
CRASH_FILE_PATH="${{ steps.extract.outputs.target }}/${{ steps.extract.outputs.crash_file }}"
@@ -274,8 +274,10 @@ jobs:
274274
ARTIFACT_URL: ${{ steps.extract.outputs.artifact_url }}
275275
uses: anthropics/claude-code-action@2dca132ff0e0c4094ce6048b422c6915a071210b # v1.0.247
276276
with:
277-
# Same `vortex-claude-ci` rule as the rest of the fuzz pipeline.
278-
anthropic_federation_rule_id: ${{ vars.ANTHROPIC_FEDERATION_RULE_CI }}
277+
# This job runs in the claude-automation environment, so the OIDC subject is
278+
# `environment:claude-automation`. Only the `vortex-claude-write` rule matches
279+
# that subject. The `vortex-claude-ci` rule fails the token exchange with 401.
280+
anthropic_federation_rule_id: ${{ vars.ANTHROPIC_FEDERATION_RULE_WRITE }}
279281
anthropic_organization_id: ${{ vars.ANTHROPIC_ORGANIZATION_ID }}
280282
anthropic_service_account_id: ${{ vars.ANTHROPIC_SERVICE_ACCOUNT_ID }}
281283
# Use the App token (not GITHUB_TOKEN) so the committed fix branch and

0 commit comments

Comments
 (0)