Skip to content

fix(mortsom): download artifacts without forwarding the token - #930

Merged
grunch merged 2 commits into
mainfrom
fix/mortsom-artifact-download
Nov 12, 2026
Merged

grunch merged 2 commits into
mainfrom
fix/mortsom-artifact-download

Conversation

@grunch

@grunch grunch commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Linked issue

None — found while looking at why #919's Mortsom verdict is inconclusive. Maintainer change.

Type

fix

What changes and why

The Mortsom verdict job could never read a run's artifacts. archive_download_url answers with a 302 to signed blob storage, and urllib follows it forwarding the Authorization: Bearer header, which the storage refuses with HTTP 401: Server failed to authenticate the request. With no summaries read, every verdict became inconclusive: incomplete-run, and the baselines were unreadable too (baseline none) — e.g. #919 and #929. GitHub._download now asks the API without following redirects and fetches the Location without the token.

Affected flow

No app flow. Only .github/mortsom/run_verdict.py (GitHub.artifact_json → new GitHub._download), run by mortsom-verdict.yml on workflow_run.

Blast radius

Only artifact downloads change; every other API call still goes through _open unchanged. The token is now sent to api.github.com only, never to the storage host. Artifacts are still parsed as size-limited data, never executed. Because this PR modifies the gate, its own Mortsom verdict is expected to be inconclusive: gate-modified; the fix shows on the next PR after merge (workflow_run runs the scripts from main).

Platforms tested

Linux (Python 3, stdlib only), against the real GitHub API.

Manual testing

Setup

A gh login with read access to the repo.

Steps

  1. On main: cd .github/mortsom && GITHUB_TOKEN=$(gh auth token) python3 -c "import os, run_verdict as rv; gh = rv.GitHub('MostroP2P/app', os.environ['GITHUB_TOKEN']); a = gh.run_artifacts(42689719809); print(len(gh.artifact_json(a['mortsom-pr-plain'])))" — prints ::warning::cannot read artifact mortsom-pr-plain: HTTP Error 401 and 0.
  2. Same command on this branch — prints 16 (bond: 15, meta: 1), the summaries of fix: announce an expiry and a taker who left #919's run.

Not covered

A full verdict run in Actions: it only happens from main, after merge.

Screenshots

No visible change.

Automated tests

TestArtifactDownload.test_the_token_is_not_sent_to_the_storage_the_api_redirects_to (fc5b7bd, fails on main): two real local HTTP servers, an API that answers 302 and a storage that answers 401 when it sees an Authorization header, like Azure. It asserts the storage receives no token and the zip's JSON is read.

python3 -m unittest discover -s .github/mortsom/tests → Ran 46 tests … OK.

Checklist

  • cd rust && cargo fmt --check && cargo clippy -- -D warnings && cargo test pass locally — no Rust change
  • dart format --set-exit-if-changed ., flutter analyze and flutter test pass locally — no Dart change
  • Changed rust/src/api/ or an .arb: n/a
  • New or changed user-facing text: n/a
  • Changed an automation identifier: n/a
  • Protocol or transport change: n/a
  • Behaviour or contract change: n/a (gate internals; docs/MORTSOM_PR_E2E_SPEC.md unchanged)
  • At most 1,500 changed lines
  • Commits are signed
  • I ran the Manual testing steps myself and can explain every line of this diff

AI assistance

Diagnosis, fix and test written with Claude Code; verified against the real API.

🤖 Generated with Claude Code

https://claude.ai/code/session_016wLvLzSnK7q59N5GdFz9MJ

Summary by CodeRabbit

  • Bug Fixes
    • Improved artifact downloads when the hosting service redirects requests to temporary download links. Requests now follow recognized redirects without forwarding GitHub authentication credentials, avoiding authorization failures from the download host. If a redirect does not include a destination, the original HTTP error is preserved.

grunch and others added 2 commits November 12, 2026 14:36
The artifact API redirects to signed blob storage, and urllib forwarded
the Authorization header along, which the storage refuses with HTTP 401.
Every PR and baseline artifact read failed, so every verdict came out
inconclusive (incomplete-run, baseline none). The redirect is now
followed by hand, without the token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016wLvLzSnK7q59N5GdFz9MJ
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T17:38:40.411313Z deb0f42 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Artifact downloads now use a separate redirect flow. The initial API request is authenticated, but the request to redirected blob storage does not forward the GitHub token. Tests verify the request headers and parsed archive contents.

Changes

Artifact download flow

Layer / File(s) Summary
Redirect handling and artifact validation
.github/mortsom/run_verdict.py, .github/mortsom/tests/test_run_verdict.py
GitHub._download handles recognized redirects without forwarding the Authorization header to redirected storage. artifact_json uses this download path. Local HTTP server tests verify the redirect and parsed archive contents.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • MostroP2P/app#924: Introduced the GitHub artifact-reading path that this change updates.
Merge Risk: Minimal · up to deb0f

Artifact downloads no longer send the GitHub token to the redirected blob storage, so summaries and baselines should be readable again. No merge-blocking risk is identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(mortsom): download artifacts without forwarding the token" names the main change: artifact downloads no longer send the GitHub token to the redirect target. It matches the raw summary, …
Description check Passed The description follows the repository template. It fills in the linked issue (none, with a reason), type (fix), what changes and why, affected flow, blast radius, platforms tested, manual testing ste…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(mortsom): download artifacts without forwarding the token" names the main change: artifact downloads no longer send the GitHub token to the redirect target. It matches the raw summary, the PR objectives, and the description, and it follows a conventional-commit style. The title is short and specific.

Full details: Description check

Explanation

The description follows the repository template. It fills in the linked issue (none, with a reason), type (fix), what changes and why, affected flow, blast radius, platforms tested, manual testing steps with expected results, screenshots, automated tests, and the checklist. Most checklist items are marked. The one unchecked item is that commits are signed, which the author has not confirmed. The AI assistance section is filled in. The 'Linked issue' section says 'None' and does not use the 'Closes #' form, which is acceptable because the author gives a reason. The description is substantially complete.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the archive trail,
The API points to a signed URL.
No token hops to blob storage,
JSON leaves the ZIP in order.
The rabbit thumps: the tests agree!

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between de04110 and deb0f42.

Files selected for processing: 2

  • .github/mortsom/run_verdict.py
  • .github/mortsom/tests/test_run_verdict.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@grunch
grunch merged commit ac9f3a8 into main Nov 12, 2026
12 checks passed
@grunch
grunch deleted the fix/mortsom-artifact-download branch November 12, 2026 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant