Skip to content

feat(cli): upload fork PRs on v2 by swapping the job's GITHUB_TOKEN - #1293

Merged
trunk-io[bot] merged 2 commits into
mainfrom
tylerbeebe/trunk-23482-analytics-cli-upload-fork-prs-on-v2
Nov 9, 2026
Merged

trunk-io[bot] merged 2 commits into
mainfrom
tylerbeebe/trunk-23482-analytics-cli-upload-fork-prs-on-v2

Conversation

@acatxnamedvirtue

@acatxnamedvirtue acatxnamedvirtue commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

On GitHub Actions, an upload of a fork pull request with --allow-forked-pr-uploads, no token, no public repo id and a test collection id can now upload over Trunk API v2. Until now it always used v1, and 1.0.0 is v2-only.

How it works

  • The run asks the decision route the way v1's collection lane does: the x-trunk-allow-forked-pr-uploads header and no credential (trunk-io/trunk#35089).
  • On v2 it swaps the job's GITHUB_TOKEN, the PR number and pull_request.head.sha at POST /v2/auth/github-actions/login. This is the same lane impacted targets uses, live in trunk2 since #7717/#7718.
  • It then sends that login on x-trunk-token, never Authorization, on the upload, quarantine-status and all-quarantined-tests calls.
  • Any failure keeps the run on v1's collection lane, as today: no GITHUB_TOKEN, or a refused or unreadable swap. It logs one warning with the HTTP status and the server's error code. The GITHUB_TOKEN and the login are never logged.

What does not change

  • Runs with a token or a public repo id.
  • Credential-free runs that are not a GitHub Actions fork PR (for example protected-branch runs, or a CircleCI fork build). They still never ask the decision route and stay on v1. They need a v2 API key before v1 retires.

Out of scope: test-runner plugins, login caching, renewal and a separate 429 retry.

The v2 client's credential is now a small enum: an API key on Authorization, or a Trunk login on x-trunk-token. Accepting a Trunk JWT for --token in 1.0.0 (TRUNK-23372) can reuse it.

The --allow-forked-pr-uploads help now says it works with no credential on v1, and on v2 only for a fork PR on GitHub Actions, using the job's GITHUB_TOKEN. analytics-uploader passes it by default (trunk-io/analytics-uploader#155); when running the CLI directly, set GITHUB_TOKEN: ${{ github.token }}.

Release: this gets cherry-picked onto 0.17.x for 0.17.0. The cherry-pick has one test-file conflict (main's newer log-routing tests), resolved by keeping only the fork tests; there the fork tests assert logs on stdout, since 0.17.x does not route logs to stderr.

Tests

  • API client: the exact swap body; the login on x-trunk-token with no Authorization; refusals (400/401/422/502/503/429/unreadable) falling back to v1; a missing GITHUB_TOKEN; a decision of v1 or 401 meaning no swap; a non-fork run never asking; a token run never swapping.
  • End-to-end CLI tests on the same cases, including that verbose logs contain neither the token nor the login.
  • Locally everything passes except 3 Swift xunit tests that need a Swift language server.

Part of TRUNK-23482

🤖 Generated with Claude Code

@trunk-io

trunk-io Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

😎 Merged successfully - details.

@acatxnamedvirtue
acatxnamedvirtue force-pushed the tylerbeebe/trunk-23482-analytics-cli-upload-fork-prs-on-v2 branch from c9773be to d2d0306 Compare November 6, 2026 18:41
@acatxnamedvirtue acatxnamedvirtue changed the title feat(cli): upload fork PRs on v2 by exchanging the job's GITHUB_TOKEN feat(cli): upload forked-PR runs on v2 with the collection's login Nov 6, 2026
@acatxnamedvirtue
acatxnamedvirtue force-pushed the tylerbeebe/trunk-23482-analytics-cli-upload-fork-prs-on-v2 branch from d2d0306 to ebc98d7 Compare November 6, 2026 19:10
@acatxnamedvirtue acatxnamedvirtue changed the title feat(cli): upload forked-PR runs on v2 with the collection's login feat(cli): upload fork PRs on v2 by swapping the job's GITHUB_TOKEN Nov 6, 2026
Comment thread api/src/client/v2.rs Resolved
Comment thread api/src/client/v2.rs Resolved
acatxnamedvirtue and others added 2 commits November 9, 2026 17:46
On GitHub Actions, an `upload` for a pull request from a fork with
--allow-forked-pr-uploads, no token, no public repo id and a test collection
id now asks the decision route with v1's collection-lane header and no
credential. On v2 it exchanges the job's GITHUB_TOKEN, the PR number and
pull_request.head.sha at POST /v2/auth/github-actions/login, the lane
impacted targets uses, and sends the login on x-trunk-token, never
Authorization, on the upload, quarantine-status and all-quarantined-tests
calls.

Any failure keeps the run on v1's collection lane, as today: a missing
GITHUB_TOKEN, or a refused or unreadable exchange, logs a warning with the
status and the server's error code. Neither the GITHUB_TOKEN nor the login is
logged.

The v2 client's credential is now a small enum: an API key on Authorization
or a Trunk login on x-trunk-token. Runs with a token or a public repo id, and
credential-free runs that are not a GitHub Actions fork PR, are unchanged:
the latter still never ask the decision route.

TRUNK-23482

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… on the swap

Review follow-up. use_upload_api_version's doc now says it takes the
decision route's answer as given, overriding it only when a fork PR's
GITHUB_TOKEN swap fails. The swap request carries
x-trunk-allow-forked-pr-uploads like the rest of the fork-lane traffic,
and the mock login route checks for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@acatxnamedvirtue
acatxnamedvirtue force-pushed the tylerbeebe/trunk-23482-analytics-cli-upload-fork-prs-on-v2 branch from 9e50900 to 5a5757f Compare November 9, 2026 17:47
@acatxnamedvirtue

Copy link
Copy Markdown
Contributor Author

/trunk merge

@trunk-io
trunk-io Bot merged commit 46eeea6 into main Nov 9, 2026
23 checks passed
acatxnamedvirtue added a commit that referenced this pull request Nov 9, 2026
…1293)

* feat(cli): upload fork PRs on v2 by swapping the job's GITHUB_TOKEN

On GitHub Actions, an `upload` for a pull request from a fork with
--allow-forked-pr-uploads, no token, no public repo id and a test collection
id now asks the decision route with v1's collection-lane header and no
credential. On v2 it exchanges the job's GITHUB_TOKEN, the PR number and
pull_request.head.sha at POST /v2/auth/github-actions/login, the lane
impacted targets uses, and sends the login on x-trunk-token, never
Authorization, on the upload, quarantine-status and all-quarantined-tests
calls.

Any failure keeps the run on v1's collection lane, as today: a missing
GITHUB_TOKEN, or a refused or unreadable exchange, logs a warning with the
status and the server's error code. Neither the GITHUB_TOKEN nor the login is
logged.

The v2 client's credential is now a small enum: an API key on Authorization
or a Trunk login on x-trunk-token. Runs with a token or a public repo id, and
credential-free runs that are not a GitHub Actions fork PR, are unchanged:
the latter still never ask the decision route.

TRUNK-23482

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(api): say the decision route is trusted, and send the fork opt-in on the swap

Review follow-up. use_upload_api_version's doc now says it takes the
decision route's answer as given, overriding it only when a fork PR's
GITHUB_TOKEN swap fails. The swap request carries
x-trunk-allow-forked-pr-uploads like the rest of the fork-lane traffic,
and the mock login route checks for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 46eeea6)
acatxnamedvirtue added a commit that referenced this pull request Nov 13, 2026
analytics-cli 1.0.0 always uses v2. The CLI and the test-runner plugins
that share the `api` crate (`test_report`, and through it the rspec gem's
native extension) make no v1 call and no `getUploadApiVersion` call.

- The v1 upload and quarantine client (`createBundleUpload`,
  `getQuarantineConfig`) and the `getUploadApiVersion` decision are gone,
  with their types: `UploadApiVersion`, `UploadApiDecision`,
  `GetUploadApiVersionRequest/Response`, `GetQuarantineConfigResponse`
  and the v1-only `CreateBundleUploadResponse.key`.
- `test_report` drops its on-disk API-version cache. Its quarantine cache
  keeps the `#v2` key suffix, so a v1 entry from 0.17.x is never read.
- The collection inference and "Trunk has no collection" skip that 0.17.x
  read from the decision are gone, with the `UPLOAD_SKIPPED` notice.
- The fork lane keeps #1293's v2 path: a credential-free GitHub Actions
  fork PR run swaps its `GITHUB_TOKEN` at
  `POST /v2/auth/github-actions/login` and sends the login on
  `x-trunk-token`. There is no v1 fallback: a refused swap, a missing
  `GITHUB_TOKEN`, or `--allow-forked-pr-uploads` with no token outside a
  fork PR uploads nothing and says why.
- 4xx bodies are read as public-api's `{"error": {"code", "message"}}`
  envelope; v1's top-level shape and its org-slug 404 hint are gone.
- The mock server serves the v2 routes, and the CLI, plugin and client
  tests run against them. The smoke steps that exercised v1's
  credential-free lane are removed.

Telemetry is unchanged: it still goes to trunk1's telemetry service with
the token on `x-api-token`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acatxnamedvirtue added a commit that referenced this pull request Nov 13, 2026
…-23372)

analytics-cli 1.0.0 reads what `--token` / `TRUNK_API_TOKEN` holds before
it calls Trunk:

- `trunk_v2_...` is a v2 API key, sent as `Authorization: Bearer` for the
  gateway to exchange.
- Three non-empty base64url segments is a Trunk JWT, sent on
  `x-trunk-token` (#1293's header) and never as a bearer.
- Anything else is the organization token, refused before any call with
  how to create a v2 key (Settings → Developer → API Keys), the Upload
  test results permission it needs, and the 0.17.x pin. `upload` and
  `test` exit with an error, and `test` refuses before running the tests.
  The fork lane's `GITHUB_TOKEN` exchange is unchanged.

On the three CLI endpoints, a 403 `INSUFFICIENT_PERMISSIONS` names the
missing `upload_test_results` permission group and how to grant it, and
a 401 for a JWT says it is expired or invalid (with its `exp` when past)
and to re-run `trunk login --api-key` or pass an API key. The error
report shows that explanation in place of the generic org-slug hint.

A Trunk JWT lasts 15 minutes (auth-hydra's `ttl.access_token`), which a
long `test` run or a plugin that looks up quarantine early and uploads
late can outlive. The CLI does not refresh it; the 401 message and the
docs say to mint it right before the upload step.

`test_report` and the rspec gem apply the same rule: the gem asks the
native extension (`RSpec::Trunk.token_refusal`) and stays off with a
warning for an organization token.

Telemetry is unchanged and still sends the token on `x-api-token`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acatxnamedvirtue added a commit that referenced this pull request Nov 13, 2026
analytics-cli 1.0.0 always uses v2. The CLI and the test-runner plugins
that share the `api` crate (`test_report`, and through it the rspec gem's
native extension) make no v1 call and no `getUploadApiVersion` call.

- The v1 upload and quarantine client (`createBundleUpload`,
  `getQuarantineConfig`) and the `getUploadApiVersion` decision are gone,
  with their types: `UploadApiVersion`, `UploadApiDecision`,
  `GetUploadApiVersionRequest/Response`, `GetQuarantineConfigResponse`
  and the v1-only `CreateBundleUploadResponse.key`.
- `test_report` drops its on-disk API-version cache. Its quarantine cache
  keeps the `#v2` key suffix, so a v1 entry from 0.17.x is never read.
- The collection inference and "Trunk has no collection" skip that 0.17.x
  read from the decision are gone, with the `UPLOAD_SKIPPED` notice.
- The fork lane keeps #1293's v2 path: a credential-free GitHub Actions
  fork PR run swaps its `GITHUB_TOKEN` at
  `POST /v2/auth/github-actions/login` and sends the login on
  `x-trunk-token`. There is no v1 fallback: a refused swap, a missing
  `GITHUB_TOKEN`, or `--allow-forked-pr-uploads` with no token outside a
  fork PR uploads nothing and says why.
- 4xx bodies are read as public-api's `{"error": {"code", "message"}}`
  envelope; v1's top-level shape and its org-slug 404 hint are gone.
- The mock server serves the v2 routes, and the CLI, plugin and client
  tests run against them. The smoke steps that exercised v1's
  credential-free lane are removed.

Telemetry is unchanged: it still goes to trunk1's telemetry service with
the token on `x-api-token`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acatxnamedvirtue added a commit that referenced this pull request Nov 13, 2026
…-23372)

analytics-cli 1.0.0 reads what `--token` / `TRUNK_API_TOKEN` holds before
it calls Trunk:

- `trunk_v2_...` is a v2 API key, sent as `Authorization: Bearer` for the
  gateway to exchange.
- Three non-empty base64url segments is a Trunk JWT, sent on
  `x-trunk-token` (#1293's header) and never as a bearer.
- Anything else is the organization token, refused before any call with
  how to create a v2 key (Settings → Developer → API Keys), the Upload
  test results permission it needs, and the 0.17.x pin. `upload` and
  `test` exit with an error, and `test` refuses before running the tests.
  The fork lane's `GITHUB_TOKEN` exchange is unchanged.

On the three CLI endpoints, a 403 `INSUFFICIENT_PERMISSIONS` names the
missing `upload_test_results` permission group and how to grant it, and
a 401 for a JWT says it is expired or invalid (with its `exp` when past)
and to re-run `trunk login --api-key` or pass an API key. The error
report shows that explanation in place of the generic org-slug hint.

A Trunk JWT lasts 15 minutes (auth-hydra's `ttl.access_token`), which a
long `test` run or a plugin that looks up quarantine early and uploads
late can outlive. The CLI does not refresh it; the 401 message and the
docs say to mint it right before the upload step.

`test_report` and the rspec gem apply the same rule: the gem asks the
native extension (`RSpec::Trunk.token_refusal`) and stays off with a
warning for an organization token.

Telemetry is unchanged and still sends the token on `x-api-token`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acatxnamedvirtue added a commit that referenced this pull request Nov 16, 2026
analytics-cli 1.0.0 always uses v2. The CLI and the test-runner plugins
that share the `api` crate (`test_report`, and through it the rspec gem's
native extension) make no v1 call and no `getUploadApiVersion` call.

- The v1 upload and quarantine client (`createBundleUpload`,
  `getQuarantineConfig`) and the `getUploadApiVersion` decision are gone,
  with their types: `UploadApiVersion`, `UploadApiDecision`,
  `GetUploadApiVersionRequest/Response`, `GetQuarantineConfigResponse`
  and the v1-only `CreateBundleUploadResponse.key`.
- `test_report` drops its on-disk API-version cache. Its quarantine cache
  keeps the `#v2` key suffix, so a v1 entry from 0.17.x is never read.
- The collection inference and "Trunk has no collection" skip that 0.17.x
  read from the decision are gone, with the `UPLOAD_SKIPPED` notice.
- The fork lane keeps #1293's v2 path: a credential-free GitHub Actions
  fork PR run swaps its `GITHUB_TOKEN` at
  `POST /v2/auth/github-actions/login` and sends the login on
  `x-trunk-token`. There is no v1 fallback: a refused swap, a missing
  `GITHUB_TOKEN`, or `--allow-forked-pr-uploads` with no token outside a
  fork PR uploads nothing and says why.
- 4xx bodies are read as public-api's `{"error": {"code", "message"}}`
  envelope; v1's top-level shape and its org-slug 404 hint are gone.
- The mock server serves the v2 routes, and the CLI, plugin and client
  tests run against them. The smoke steps that exercised v1's
  credential-free lane are removed.

Telemetry is unchanged: it still goes to trunk1's telemetry service with
the token on `x-api-token`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acatxnamedvirtue added a commit that referenced this pull request Nov 16, 2026
…-23372)

analytics-cli 1.0.0 reads what `--token` / `TRUNK_API_TOKEN` holds before
it calls Trunk:

- `trunk_v2_...` is a v2 API key, sent as `Authorization: Bearer` for the
  gateway to exchange.
- Three non-empty base64url segments is a Trunk JWT, sent on
  `x-trunk-token` (#1293's header) and never as a bearer.
- Anything else is the organization token, refused before any call with
  how to create a v2 key (Settings → Developer → API Keys), the Upload
  test results permission it needs, and the 0.17.x pin. `upload` and
  `test` exit with an error, and `test` refuses before running the tests.
  The fork lane's `GITHUB_TOKEN` exchange is unchanged.

On the three CLI endpoints, a 403 `INSUFFICIENT_PERMISSIONS` names the
missing `upload_test_results` permission group and how to grant it, and
a 401 for a JWT says it is expired or invalid (with its `exp` when past)
and to re-run `trunk login --api-key` or pass an API key. The error
report shows that explanation in place of the generic org-slug hint.

A Trunk JWT lasts 15 minutes (auth-hydra's `ttl.access_token`), which a
long `test` run or a plugin that looks up quarantine early and uploads
late can outlive. The CLI does not refresh it; the 401 message and the
docs say to mint it right before the upload step.

`test_report` and the rspec gem apply the same rule: the gem asks the
native extension (`RSpec::Trunk.token_refusal`) and stays off with a
warning for an organization token.

Telemetry is unchanged and still sends the token on `x-api-token`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acatxnamedvirtue added a commit that referenced this pull request Nov 16, 2026
…-23372)

analytics-cli 1.0.0 reads what `--token` / `TRUNK_API_TOKEN` holds before
it calls Trunk:

- `trunk_v2_...` is a v2 API key, sent as `Authorization: Bearer` for the
  gateway to exchange.
- Three non-empty base64url segments is a Trunk JWT, sent on
  `x-trunk-token` (#1293's header) and never as a bearer.
- Anything else is the organization token, refused before any call with
  how to create a v2 key (Settings → Developer → API Keys), the Upload
  test results permission it needs, and the 0.17.x pin. `upload` and
  `test` exit with an error, and `test` refuses before running the tests.
  The fork lane's `GITHUB_TOKEN` exchange is unchanged.

On the three CLI endpoints, a 403 `INSUFFICIENT_PERMISSIONS` names the
missing `upload_test_results` permission group and how to grant it, and
a 401 for a JWT says it is expired or invalid (with its `exp` when past)
and to re-run `trunk login --api-key` or pass an API key. The error
report shows that explanation in place of the generic org-slug hint.

A Trunk JWT lasts 15 minutes (auth-hydra's `ttl.access_token`), which a
long `test` run or a plugin that looks up quarantine early and uploads
late can outlive. The CLI does not refresh it; the 401 message and the
docs say to mint it right before the upload step.

`test_report` and the rspec gem apply the same rule: the gem asks the
native extension (`RSpec::Trunk.token_refusal`) and stays off with a
warning for an organization token.

Telemetry is unchanged and still sends the token on `x-api-token`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acatxnamedvirtue added a commit that referenced this pull request Nov 16, 2026
analytics-cli 1.0.0 always uses v2. The CLI and the test-runner plugins
that share the `api` crate (`test_report`, and through it the rspec gem's
native extension) make no v1 call and no `getUploadApiVersion` call.

- The v1 upload and quarantine client (`createBundleUpload`,
  `getQuarantineConfig`) and the `getUploadApiVersion` decision are gone,
  with their types: `UploadApiVersion`, `UploadApiDecision`,
  `GetUploadApiVersionRequest/Response`, `GetQuarantineConfigResponse`
  and the v1-only `CreateBundleUploadResponse.key`.
- `test_report` drops its on-disk API-version cache. Its quarantine cache
  keeps the `#v2` key suffix, so a v1 entry from 0.17.x is never read.
- The collection inference and "Trunk has no collection" skip that 0.17.x
  read from the decision are gone, with the `UPLOAD_SKIPPED` notice.
- The fork lane keeps #1293's v2 path: a credential-free GitHub Actions
  fork PR run swaps its `GITHUB_TOKEN` at
  `POST /v2/auth/github-actions/login` and sends the login on
  `x-trunk-token`. There is no v1 fallback: a refused swap, a missing
  `GITHUB_TOKEN`, or `--allow-forked-pr-uploads` with no token outside a
  fork PR uploads nothing and says why.
- 4xx bodies are read as public-api's `{"error": {"code", "message"}}`
  envelope; v1's top-level shape and its org-slug 404 hint are gone.
- The mock server serves the v2 routes, and the CLI, plugin and client
  tests run against them. The smoke steps that exercised v1's
  credential-free lane are removed.

Telemetry is unchanged: it still goes to trunk1's telemetry service with
the token on `x-api-token`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acatxnamedvirtue added a commit that referenced this pull request Nov 16, 2026
…-23372)

analytics-cli 1.0.0 reads what `--token` / `TRUNK_API_TOKEN` holds before
it calls Trunk:

- `trunk_v2_...` is a v2 API key, sent as `Authorization: Bearer` for the
  gateway to exchange.
- Three non-empty base64url segments is a Trunk JWT, sent on
  `x-trunk-token` (#1293's header) and never as a bearer.
- Anything else is the organization token, refused before any call with
  how to create a v2 key (Settings → Developer → API Keys), the Upload
  test results permission it needs, and the 0.17.x pin. `upload` and
  `test` exit with an error, and `test` refuses before running the tests.
  The fork lane's `GITHUB_TOKEN` exchange is unchanged.

On the three CLI endpoints, a 403 `INSUFFICIENT_PERMISSIONS` names the
missing `upload_test_results` permission group and how to grant it, and
a 401 for a JWT says it is expired or invalid (with its `exp` when past)
and to re-run `trunk login --api-key` or pass an API key. The error
report shows that explanation in place of the generic org-slug hint.

A Trunk JWT lasts 15 minutes (auth-hydra's `ttl.access_token`), which a
long `test` run or a plugin that looks up quarantine early and uploads
late can outlive. The CLI does not refresh it; the 401 message and the
docs say to mint it right before the upload step.

`test_report` and the rspec gem apply the same rule: the gem asks the
native extension (`RSpec::Trunk.token_refusal`) and stays off with a
warning for an organization token.

Telemetry is unchanged and still sends the token on `x-api-token`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
trunk-io Bot pushed a commit that referenced this pull request Nov 16, 2026
* feat(cli)!: use only the Trunk API v2 routes (TRUNK-23148)

analytics-cli 1.0.0 always uses v2. The CLI and the test-runner plugins
that share the `api` crate (`test_report`, and through it the rspec gem's
native extension) make no v1 call and no `getUploadApiVersion` call.

- The v1 upload and quarantine client (`createBundleUpload`,
  `getQuarantineConfig`) and the `getUploadApiVersion` decision are gone,
  with their types: `UploadApiVersion`, `UploadApiDecision`,
  `GetUploadApiVersionRequest/Response`, `GetQuarantineConfigResponse`
  and the v1-only `CreateBundleUploadResponse.key`.
- `test_report` drops its on-disk API-version cache. Its quarantine cache
  keeps the `#v2` key suffix, so a v1 entry from 0.17.x is never read.
- The collection inference and "Trunk has no collection" skip that 0.17.x
  read from the decision are gone, with the `UPLOAD_SKIPPED` notice.
- The fork lane keeps #1293's v2 path: a credential-free GitHub Actions
  fork PR run swaps its `GITHUB_TOKEN` at
  `POST /v2/auth/github-actions/login` and sends the login on
  `x-trunk-token`. There is no v1 fallback: a refused swap, a missing
  `GITHUB_TOKEN`, or `--allow-forked-pr-uploads` with no token outside a
  fork PR uploads nothing and says why.
- 4xx bodies are read as public-api's `{"error": {"code", "message"}}`
  envelope; v1's top-level shape and its org-slug 404 hint are gone.
- The mock server serves the v2 routes, and the CLI, plugin and client
  tests run against them. The smoke steps that exercised v1's
  credential-free lane are removed.

Telemetry is unchanged: it still goes to trunk1's telemetry service with
the token on `x-api-token`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(cli): remove the deprecation notice, which nothing emits in 1.0.0 (TRUNK-23148)

The flags it warned about are gone, so no run reports a deprecation. The
summary schema's notice kinds are now BEP_PARSE_ERROR only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(test_report): drop the deprecation-notice loop the previous commit left (TRUNK-23148)

The rspec gem printed deprecation notices on stderr; with the variant gone,
there are none to print.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
acatxnamedvirtue added a commit that referenced this pull request Nov 17, 2026
…-23372)

analytics-cli 1.0.0 reads what `--token` / `TRUNK_API_TOKEN` holds before
it calls Trunk:

- `trunk_v2_...` is a v2 API key, sent as `Authorization: Bearer` for the
  gateway to exchange.
- Three non-empty base64url segments is a Trunk JWT, sent on
  `x-trunk-token` (#1293's header) and never as a bearer.
- Anything else is the organization token, refused before any call with
  how to create a v2 key (Settings → Developer → API Keys), the Upload
  test results permission it needs, and the 0.17.x pin. `upload` and
  `test` exit with an error, and `test` refuses before running the tests.
  The fork lane's `GITHUB_TOKEN` exchange is unchanged.

On the three CLI endpoints, a 403 `INSUFFICIENT_PERMISSIONS` names the
missing `upload_test_results` permission group and how to grant it, and
a 401 for a JWT says it is expired or invalid (with its `exp` when past)
and to re-run `trunk login --api-key` or pass an API key. The error
report shows that explanation in place of the generic org-slug hint.

A Trunk JWT lasts 15 minutes (auth-hydra's `ttl.access_token`), which a
long `test` run or a plugin that looks up quarantine early and uploads
late can outlive. The CLI does not refresh it; the 401 message and the
docs say to mint it right before the upload step.

`test_report` and the rspec gem apply the same rule: the gem asks the
native extension (`RSpec::Trunk.token_refusal`) and stays off with a
warning for an organization token.

Telemetry is unchanged and still sends the token on `x-api-token`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
trunk-io Bot pushed a commit that referenced this pull request Nov 17, 2026
…-23372) (#1314)

* feat(cli)!: take only a v2 API key or a Trunk JWT (TRUNK-23149, TRUNK-23372)

analytics-cli 1.0.0 reads what `--token` / `TRUNK_API_TOKEN` holds before
it calls Trunk:

- `trunk_v2_...` is a v2 API key, sent as `Authorization: Bearer` for the
  gateway to exchange.
- Three non-empty base64url segments is a Trunk JWT, sent on
  `x-trunk-token` (#1293's header) and never as a bearer.
- Anything else is the organization token, refused before any call with
  how to create a v2 key (Settings → Developer → API Keys), the Upload
  test results permission it needs, and the 0.17.x pin. `upload` and
  `test` exit with an error, and `test` refuses before running the tests.
  The fork lane's `GITHUB_TOKEN` exchange is unchanged.

On the three CLI endpoints, a 403 `INSUFFICIENT_PERMISSIONS` names the
missing `upload_test_results` permission group and how to grant it, and
a 401 for a JWT says it is expired or invalid (with its `exp` when past)
and to re-run `trunk login --api-key` or pass an API key. The error
report shows that explanation in place of the generic org-slug hint.

A Trunk JWT lasts 15 minutes (auth-hydra's `ttl.access_token`), which a
long `test` run or a plugin that looks up quarantine early and uploads
late can outlive. The CLI does not refresh it; the 401 message and the
docs say to mint it right before the upload step.

`test_report` and the rspec gem apply the same rule: the gem asks the
native extension (`RSpec::Trunk.token_refusal`) and stays off with a
warning for an organization token.

Telemetry is unchanged and still sends the token on `x-api-token`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(cli): describe the JWT that `trunk flakytests upload` passes (TRUNK-23916)

`trunk login --api-key` was canceled. A Trunk JWT now reaches analytics-cli
from `trunk flakytests upload`, exchanged from a key stored with
`trunk auth api-key set`, and can have about a minute left, so the help
text, the expired-JWT message and the docs point there instead of telling
users to mint a 15-minute JWT themselves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(rspec): drop the canceled `trunk login --api-key` from the token comment

TRUNK-23371 is canceled; the JWT now comes from `trunk flakytests upload`,
and a gem run should use a v2 API key (see the README's Credentials).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci: run the smoke and gem tests with the v2 API key secrets (TRUNK-23149)

analytics-cli 1.x refuses the organization token, so every step that runs
the built CLI or the rspec gem now uses TRUNK_PROD_API_V2_TOKEN and
TRUNK_STAGING_API_V2_TOKEN. The Dynamic CI filter steps keep
TRUNK_PROD_ORG_API_TOKEN: they don't run analytics-cli.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(cli): link to the API keys page and date the 0.17.x organization-token pin (TRUNK-23149)

Review follow-up. Messages, the --token help and the README link to
https://app.trunk.io/settings/developer/api-tokens, which the web app sends to
the viewer's org. The organization token keeps working on 0.17.x until
December 1, 2027.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci(release): install qemu-user-binfmt for the ppc64le and s390x smoke tests

ubuntu-latest is now ubuntu-26.04, where qemu-user-static is a virtual
package with no installation candidate, so apt-get exits 100 before the
smoke test runs. qemu-user-binfmt provides the user-mode emulators and
registers binfmt_misc on both 24.04 and 26.04.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants