storage 9.0.0: a custom apiEndpoint always authenticates now (useAuthWithCustomEndpoint is ignored), so emulators need credentials

オープン
#9,873 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

評価

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

調査の方向性

Start in handwritten/storage and trace how Storage passes apiEndpoint and useAuthWithCustomEndpoint into StorageTransport. Read StorageTransport.makeRequest alongside resumable-upload.js, which the issue says still handles custom endpoints without authentication. Reproduce with fake-gcs-server and verify that JSON API calls work without credentials when the option is false, while authentication is used when it is true.

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

説明

Package: @google-cloud/storage (handwritten/storage)

Environment

  • @google-cloud/storage 9.0.0 (gaxios 8.3.3, google-auth-library 11.3.4)
  • Node 22.23.4 (same under Bun 1.4.4)
  • No Google credentials in the environment: no GOOGLE_APPLICATION_CREDENTIALS, no gcloud ADC, not on GCP

Steps to reproduce

Against fake-gcs-server (docker run -p 4443:4443 fsouza/fake-gcs-server -scheme http -backend memory):

import { Storage } from "@google-cloud/storage";

for (const opts of [{}, { useAuthWithCustomEndpoint: false }]) {
  const storage = new Storage({ projectId: "p", apiEndpoint: "http://127.0.0.1:4443", ...opts });
  try {
    const [exists] = await storage.bucket("repro-bucket").file("missing.txt").exists();
    console.log(opts, "exists() answered", exists);
  } catch (e) {
    console.log(opts, e.message);
  }
}

Actual (9.0.0)

{} Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
{ useAuthWithCustomEndpoint: false } Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.

The same happens for every JSON API call (getMetadata, download, createReadStream, copy, delete, getFiles, save with resumable: false). Resumable uploads still work without credentials.

Expected (8.4.0)

{} exists() answered false
{ useAuthWithCustomEndpoint: false } exists() answered false

A custom endpoint is not authenticated unless useAuthWithCustomEndpoint is true, which is still what the option's JSDoc says in 9.0.0 ("Controls whether or not to use authentication when using a custom endpoint", default false).

Cause

Storage still sets customEndpoint and passes useAuthWithCustomEndpoint to StorageTransport, which stores it but never reads it: makeRequest sends every request through this.authClient.request() (a GoogleAuth), so credentials are looked up whatever the endpoint. resumable-upload.js still checks useAuthWithCustomEndpoint and uses plain gaxios for a custom endpoint, which is why resumable uploads keep working. MIGRATION.md doesn't mention the change.

Workaround

new Storage({ apiEndpoint, authClient: new PassThroughClient() }), with PassThroughClient from google-auth-library.

Suggested fix

In StorageTransport.makeRequest, send the request without authentication when the endpoint is custom and useAuthWithCustomEndpoint is not true, as 8.x did (for example through the plain gaxios instance, as resumable-upload.js does).

主要言語
TypeScript
スター
3.2k
フォーク
732
平均マージ
2日 11時間
マージ済み PR(30日)
99

環境構築

はじめの一歩

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

googleapis/google-cloud-node のほかの issue

googleapis/google-cloud-node の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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