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

Cerrado
#303 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
50/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
typescript
Área
cli, cloud

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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>
└
Lenguaje dominante
TypeScript
Estrellas
993
Forks
65
Merge medio
18 h 28 min
PR fusionados (30 d)
207

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de cloudflare/cf

Todos los issues de cloudflare/cf

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.