Skip to content

tools/testing: nested cache sets send the anonymous ghcr.io token - #14719

Merged
TrapsterDK merged 4 commits into
mainfrom
cloud/14718
Nov 23, 2026
Merged

TrapsterDK merged 4 commits into
mainfrom
cloud/14718

Conversation

@TrapsterDK

Copy link
Copy Markdown
Collaborator

Pull Request

Linked Issue

Closes #14718

Changes

  • The nested_repository_cache extension declares each cache entry with a new nested_cache_file repository rule instead of http_file. It downloads with the entry's integrity; for ghcr.io URLs it first tries without a token, then retries ghcr.io only with an anonymous pull token. This is what the homebrew swift-format bottle in tools/testing/nested_cache/apple.txt needs: without the token, ghcr.io answers 401 and //apple/tests:consumer_build_test fails analysis on macOS.
  • The token code moves from core/toolchain.bzl into core/ghcr.bzl (ghcr_pull_scope, ghcr_headers), so the swift-format pin and the nested cache share it.
  • //core/tests:ghcr_unit covers the scope parsing and the header.

Verification

Tested:

  • bazel test //core/tests:ghcr_unit //core/tests:repo_unit //core/tests:toolchain //tools/testing:nested_cache_update_test: all pass.
  • //core/tests:pins fails on 5 julia_src_* URL checks; the same 5 fail on unmodified main.
  • bazel fetch --repo=@@+nested_repository_cache+nested_cache_a4890bc5… --repository_cache=<empty> --force: the unauthenticated try gets the same 401 as the macOS run, then the token retry fetches the 5.7 MB blob and the integrity check passes.
  • bazel build @@+nested_repository_cache+nested_cache_apple//:cache and …nested_cache_harness//:cache: both build on Linux.
  • tools/dx check --apply on every touched file: no findings.

Not run: the nested macOS lock refresh (the nested JVM rejects the cloud proxy CA). I'm requesting it below with /lock-refresh nested=true. This PR stays draft until that run passes on macos_arm64.


Generated by Claude Code

@TrapsterDK TrapsterDK added the needs-review Touches review paths; needs a second-session Review: comment label Nov 23, 2026 — with Claude

Copy link
Copy Markdown
Collaborator Author

/lock-refresh nested=true


Generated by Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

Lock refresh (nested=true) started on cloud/14718: https://github.com/devhusdk/rules_dx/actions/runs/45142959583

Copy link
Copy Markdown
Collaborator Author

Red affected tests shards (run 45142774410): the core/toolchain.bzl change makes the affected set broad, so it picks up many tests main fails too. I ran the suspects on this head locally:

  • Mine: //tools/ci:pin_locations_test. The ghcr.io token fetch moved to core/ghcr.bzl, so its no-digest allowlist line has to move with it (count unchanged). The fix is committed (ef11729) and I'll push it once the running /lock-refresh nested=true (45142959583) has pushed, so its plain git push doesn't fail.
  • Not this PR's (none of their findings name core/ghcr.bzl, core/toolchain.bzl, tools/testing/extensions.bzl or nested_repository_cache.bzl):
    • repo_rule_refetch_test: a scala config_extension.bzl line; my two entries match the allowlist.
    • pin_locations_test (also): android repos.bzl and MODULE.bazel counts.
    • starlark_docs_test: digest_problems docstring, not touched here.
    • dx_nested_test: rules_flutter_pin_matches_the_root_module.
    • apple_consumer_test / dart_consumer_test: dx init fixture BUILD diffs.
    • root_module_test: dev-registration of musl rust toolchains.
    • The other //tools/ci guards and the core/modules, config, gazelle and docs failures, which are the known main red set.

Generated by Claude Code

Copy link
Copy Markdown
Collaborator Author

Pushed ef11729 (the pin_locations allowlist line moves to core/ghcr.bzl). The lock refresh's nested record (linux_x86_64) leg failed on //deploy/private/release/tests:release_consumer_smoke_test: the README quickstart's dx check //app/... gets a clippy must_use_candidate finding. That's the same test that failed in the original run 45077581586, before this change, so it isn't this PR's. The fix #14718 needs is the nested record (macos_arm64) leg, which is still running. Stays draft until that leg is green.


Generated by Claude Code

@TrapsterDK
TrapsterDK marked this pull request as ready for review November 23, 2026 09:48
@TrapsterDK TrapsterDK added the train Tested; land via merge train label Nov 23, 2026 — with Claude

Copy link
Copy Markdown
Collaborator Author

macOS evidence: in lock-refresh run 45142959583, nested record (macos_arm64) passes //apple/tests:consumer_build_test (1115 s). That's the target that failed analysis on the ghcr.io 401 in runs 45073337721 and 45077581586. The log shows the expected unauthenticated 401 on the swift-format blob, then the token retry fetches it. The leg's only failure is //deploy/private/release/tests:release_consumer_smoke_test (README quickstart, clippy must_use_candidate). It fails the same way on the linux_x86_64 and windows_x86_64 legs and in the pre-change run 45077581586, so it's a main failure. Because of it the refresh committed no locks, so the locks need re-recording once main fixes the quickstart. Marked ready with train; needs-review stays because core/ is touched.


Generated by Claude Code

@TrapsterDK

Copy link
Copy Markdown
Collaborator Author

Review: approve

  • tools/testing/nested_repository_cache.bzl:68,70: two inline # comments; AGENTS.md deletes them by default. Drop both.
  • tools/ci/pin_locations_allowlist.txt:34: core/ghcr.bzl no-digest 1 replaces the core/toolchain.bzl line. It is the same token URL moved and the count is unchanged, so the allowlist does not grow.
  • tools/testing/nested_repository_cache.bzl:71: the scope comes from ghcr[0] only. That is fine for current lists. An entry with ghcr.io URLs from two different repositories would get a token for the first one only.
  • Token header goes only to ghcr.io URLs, the integrity check covers both attempts, and the macOS lock-refresh evidence (run 45142959583) shows the 401 then retry path.

🤖 Generated with Claude Code

Copy link
Copy Markdown
Collaborator Author

Dropped both inline comments in nested_cache_file (3e00443). @@+nested_repository_cache+nested_cache_apple//:cache still builds and tools/dx check is clean on the file. On the ghcr[0] scope: agreed, every current entry has a single ghcr.io URL, so I left it as is.


Generated by Claude Code

@TrapsterDK

Copy link
Copy Markdown
Collaborator Author

Merge train: dropped, //tools/ci:test_budget_test fails on this PR's files and passes the main baseline once this PR is reverted: core/tests/ghcr_tests.bzl no-size 1: 0 allowed; make the test small (and core/tests/BUILD.bazel no-size 34: 32 allowed, main has 33). The new ghcr_unit test needs size = "small".

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xut2hxcqqAoDeuSr83mscS

claude and others added 4 commits November 23, 2026 14:04
The apple nested cache set lists the homebrew swift-format bottle on
ghcr.io, which answers 401 without a bearer token, so the macOS nested
lock refresh failed. Cache entries now come from nested_cache_file, which
retries ghcr.io URLs with an anonymous pull token. The token helper moves
to core/ghcr.bzl and core/toolchain.bzl uses it too.

Closes #14718

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xut2hzfCX44JNoyXRYMq2N
…/ghcr.bzl

The anonymous token fetch moved from core/toolchain.bzl to core/ghcr.bzl,
so its no-digest allowlist entry moves with it. The count is unchanged.

Part of #14718

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xut2hzfCX44JNoyXRYMq2N
Review follow-up.

Part of #14718

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xut2hzfCX44JNoyXRYMq2N
@TrapsterDK

Copy link
Copy Markdown
Collaborator Author

Fixed: //tools/ci:test_budget_test flagged core/tests/ghcr_tests.bzl no-size 1 and one more unsized test in core/tests/BUILD.bazel. ghcr_unit_tests now takes size and passes it to starlark_test, and the BUILD call sets size = "small", the same pattern as lock_hub_tests (c172166). Rebased onto current origin/main.

Checks on this head:

  • bazel test //core/tests:all //core:all: 33 pass.
  • test_budget_test no longer names ghcr_tests.bzl, and core/tests/BUILD.bazel is back to main's count of 33.
  • The touched-file guards (test_tags, command_docs, host_program, starlark_docs, zero_compat, host_env, prose_rules, repo_rule_refetch, pin_locations) have no hits that name a touched file. The ones still red fail the same way on main.
  • //tools/testing dx_testing, module_srcs, root_layout and starlark_harness pass.

needs-review: this push changed code after the 12:04 Review: approve, so that review is stale and the PR needs a fresh one.


Generated by Claude Code

@TrapsterDK

Copy link
Copy Markdown
Collaborator Author

Review: approve

Re-reviewed at c172166 (new since the 12:04 approval: ef643a8 and c172166).

  • core/tests/ghcr_tests.bzl:34 and core/tests/BUILD.bazel:98: ghcr_unit_tests(name, size) passes size to starlark_test, and the BUILD call sets size = "small". This matches lock_hub_tests and fixes the test_budget_test no-size finding.
  • tools/testing/nested_repository_cache.bzl: both inline # comments (old lines 68 and 70) are gone. The diff adds no inline # comments, and core/tests/pins_tests.bzl is not touched.
  • tools/ci/pin_locations_allowlist.txt:34: core/ghcr.bzl no-digest 1 replaces the core/toolchain.bzl line for the same token URL, so there is no net growth.
  • core/ghcr.bzl:16 (non-blocking): the ghcr_headers docstring is long and carries a rationale clause ("ghcr.io answers 401 without one"). Consider trimming it to "Download headers with an anonymous ghcr.io pull token for scope."
  • tools/testing/nested_cache/apple.txt: the only ghcr.io URL in any cache list is a /v2/.../blobs/ URL, so ghcr_pull_scope cannot fail on today's lists.

🤖 Generated with Claude Code

Copy link
Copy Markdown
Collaborator Author

Thanks. I'm leaving the non-blocking ghcr_headers docstring trim out of this PR so the approval stays current. I'll make it in the next change that touches core/ghcr.bzl.


Generated by Claude Code

@TrapsterDK
TrapsterDK merged commit df717e1 into main Nov 23, 2026
4 checks passed
@TrapsterDK
TrapsterDK deleted the cloud/14718 branch November 23, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review Touches review paths; needs a second-session Review: comment train Tested; land via merge train

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lock-refresh nested=true: macOS apple test gets 401 from ghcr.io on homebrew download

2 participants