`cf r2 objects get` ignores `--cf-r2-jurisdiction` (10006 for buckets in the eu jurisdiction)

クローズ
#303 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
50/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
cli, cloud

調査の方向性

Start in generator/plugin/emit/handler.ts, in the bodyless raw-output branch of handler() where emitRawTail is called with an empty list, and compare it with the body-sending branches that pass headers when ctx.hasHeaders is set. The generated output is r2/objects/get.ts, so regenerate after the change. Done means cf r2 objects get sends cf-r2-jurisdiction and the generator output for that command includes the header. The issue says the earlier fix PR was closed under the beta contribution policy, so confirm with maintainers before starting.

索引モデルが issue の本文から書いたものです。

説明

Summary of the issue

cf r2 objects get accepts --cf-r2-jurisdiction, --if-none-match and --if-modified-since, but never sends them. The generated handler builds a headers map from these flags and then calls fetchRawBytes without it. As a result, objects in a bucket in the eu jurisdiction cannot be read: the API answers 10006 "The specified bucket does not exist".

r2 objects list, put and delete send the header, so only get fails.

The cause is in the generator. In generator/plugin/emit/handler.ts, the bodyless raw-output branch of handler() calls emitRawTail(ctx, " ", url, []), which leaves out the headers option. The raw branches that send a body add headers: ${HEADERS_GUARDED} when ctx.hasHeaders is set. r2/objects/get.ts is the only generated command affected.

A fix with a generator test and an MSW command test is in #302, which was closed automatically under the beta contribution policy. It passes headers on that branch and regenerates r2/objects/get.ts. Nothing else changes.

Expected behaviour

cf r2 objects get <key> --bucket-name <bucket> --cf-r2-jurisdiction eu sends cf-r2-jurisdiction: eu and writes the object body to stdout, like the other r2 objects commands.

Version of cf used

1.0.0-beta.5. The same handler code is in 1.0.0-beta.16 and on main (d72b8554).

System information and package versions
  System:
    OS: macOS 26.6.2
    CPU: (16) arm64 Apple M4 Max
    Memory: 217.30 MB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.20.0
    npm: 11.19.0
    pnpm: 12.11.1
    bun: 1.4.2

cf installed globally with bun.

Reproduction (optional)
  1. Create a bucket in the eu jurisdiction and put an object in it.
  2. Run cf r2 objects list --bucket-name <bucket> --cf-r2-jurisdiction eu. This works.
  3. Run cf r2 objects get <key> --bucket-name <bucket> --cf-r2-jurisdiction eu > out. This fails with the error below, and out is empty.

Logging globalThis.fetch shows the get request is sent with only user-agent and x-cf-cli-mode (plus Authorization), and no cf-r2-jurisdiction. With the one-line change from #302 applied to 1.0.0-beta.5, the same command returns the object.

Relevant error logs (optional)
┌ APIError
│ [10006] The specified bucket does not exist.
│ 404 Not Found · HTTP /accounts/<account-id>/r2/buckets/<bucket>/objects/<key>
└
主要言語
TypeScript
スター
993
フォーク
65
平均マージ
21時間 47分
マージ済み PR(30日)
209

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

cloudflare/cf のほかの issue

cloudflare/cf の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。