fix(atlas): list R2 buckets in every jurisdiction, not just the default - #2096
Open
timrutzen wants to merge 1 commit into
Open
fix(atlas): list R2 buckets in every jurisdiction, not just the default#2096timrutzen wants to merge 1 commit into
timrutzen wants to merge 1 commit into
Conversation
The Cloudflare collector lists R2 buckets once, without a jurisdiction. That listing returns only default-jurisdiction buckets, so an account whose buckets were created with `--jurisdiction eu` gets a 200 and an empty array, which is indistinguishable from owning no buckets at all. The asset graph then reports zero R2 buckets, permanently and silently. Jurisdiction is a request HEADER, `cf-r2-jurisdiction`, not a query parameter. `?jurisdiction=eu` is accepted and ignored, so the intuitive fix produces the same empty list as the bug. Measured against one token in the same second: header -> 3 buckets, query parameter -> 0. This threads an optional headers argument through `cf()` and `cfSoft()`, then loops the R2 listing over `default` and `eu`, recording which jurisdiction a bucket came from as an asset attribute. Buckets stay keyed by name alone. A worker's `r2_bucket` binding carries only `bucket_name`, so a jurisdiction-qualified key would break every DEPENDS_ON edge `datastoreTarget()` resolves. `fnv` is deliberately not probed: it is FedRAMP-only and 403s for ordinary accounts, which would set `partial` on every run and stop the collector ever sweeping. Tested against a live account with three `eu` buckets. Before: 0 R2 assets. After: 3, each carrying `jurisdiction: eu`, with the collector reporting complete over 22 assets and 16 edges. Default-jurisdiction accounts are unaffected beyond one extra listing call that returns empty. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
The bug
The Cloudflare collector lists R2 buckets once, without a jurisdiction:
That listing returns only default-jurisdiction buckets. An account whose buckets were created with
--jurisdiction eugets a200and an empty array, which is indistinguishable from owning no buckets at all. The asset graph then reports zero R2 buckets, permanently and silently — no error, no partial run, nothing to notice.Why the obvious fix does not work
Jurisdiction travels as a request header,
cf-r2-jurisdiction, never as a query parameter.?jurisdiction=euis accepted and silently ignored, so it returns exactly the same empty list as the bug it was meant to repair.Measured against one token, in the same second:
GET /r2/bucketsGET /r2/buckets?jurisdiction=euGET /r2/buckets+cf-r2-jurisdiction: euThe change
cf()andcfSoft()take an optionalextraheaders argument.defaultandeu, and records which jurisdiction a bucket came from as an asset attribute.Two decisions worth calling out, both in code comments:
r2_bucketbinding carries onlybucket_name, so a jurisdiction-qualified key could not be resolved bydatastoreTarget()and everyDEPENDS_ONedge to a bucket would break. Jurisdiction rides as an attribute instead.fnvis not probed. It is FedRAMP-only and403s for ordinary accounts, which would setpartialon every run and stop the collector ever sweeping.Testing
Run against a live account with three
eubuckets.jurisdiction: eu; collector reportscompleteover 22 assets and 16 edges.Default-jurisdiction accounts are unaffected beyond one extra listing call that returns empty.