(Feat): Support X-Trunk-Public-Repo-Id auth for fork PRs#1086
Open
(Feat): Support X-Trunk-Public-Repo-Id auth for fork PRs#1086
Conversation
Adds a TRUNK_PUBLIC_REPO_ID env / --public-repo-id flag so fork-PR runs that lack TRUNK_API_TOKEN can still upload bundles and fetch the quarantine list. Token-first ordering preserves existing CI behavior; the new header is sent only when the token is absent. Telemetry is skipped on the public-id path because that endpoint does not accept the new header. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1086 +/- ##
==========================================
+ Coverage 81.75% 82.17% +0.42%
==========================================
Files 69 70 +1
Lines 14917 14996 +79
==========================================
+ Hits 12195 12323 +128
+ Misses 2722 2673 -49 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for the new
X-Trunk-Public-Repo-Idheader so fork-PR runs that lackTRUNK_API_TOKENcan still upload bundles and fetch the quarantine list. See the integration guide for the server-side contract.--public-repo-idflag /TRUNK_PUBLIC_REPO_IDenv. Token-first: when both are set, the token wins. When neither is set,uploadexits with a clear message naming both env vars.createBundleUpload,getQuarantineConfig); telemetry is silently skipped on the public-id path because the telemetry endpoint does not accept the new header. S3 PUT is unchanged.Using X-Trunk-Public-Repo-Id auth (TRUNK_API_TOKEN not set; assuming fork PR)once at info level when the public-id path is taken; the id value itself is never logged.test_reportflow (is_quarantinedandpublish).Implementation
api/src/auth.rs(new):TrunkApiCredential::{Token, PublicRepoId}plusresolve(token, public_repo_id)with token-first ordering. Empty / whitespace strings count as absent.api/src/client.rs:ApiClient::newnow takes aTrunkApiCredential; the trunk-API client carries eitherx-api-tokenorx-trunk-public-repo-id. Telemetry client isOption<Client>andtelemetry_upload_metricsshort-circuits withOk(())when no token is available.cli/src/upload_command.rs:--tokenno longer required by clap;run_uploadresolves the credential andbail!s with a clear message when neither is set.test_report/src/report.rs: both call sites resolve viaTrunkApiCredentialand forwardpublic_repo_idintoUploadArgs.The integration guide also names a renamed
/v1/flaky-tests/list-quarantined-testspath; the server has wired the new auth into the existing/v1/metrics/getQuarantineConfigendpoint as well, so no endpoint migration is needed in this PR. GitHub Action (action.yml) changes live intrunk-io/analytics-uploaderand are out of scope.Test plan
cargo build --workspace— cleancargo test -p api— 20/20 (incl. 7 newauth::*tests covering token-only, public-id-only, both → token wins, empty/whitespace fall-through, neither → None)cargo test -p test_report— 6/6cargo test --workspace— all pass exceptupload_bundle_using_xcresult, which fails on this developer machine before any HTTP call ("failed to parse xcresulttool version" — local Xcode env issue, unrelated to this change)RepoForkPrUploadsConfig.enabled = true→ CLI with onlyTRUNK_PUBLIC_REPO_IDset → presigned URL returnedenabled = false→ 401 surfaced cleanly🤖 Generated with Claude Code