StripeClientBuilder throws an exception with null apiKey
まだ誰も着手していません。
評価
調査の方向性
src/main/java/com/stripe/StripeClient.java の、リンクされている StripeClientBuilder.setApiKey の実装付近から開始し、build() の検証パスを追ってください。グローバルキーを持たないクライアントが RequestOptions から認証情報を取得する方法を確認し、その後、null キーで構築が成功すること、およびリクエストごとのキーを使用する呼び出しが期待どおりに動作することを検証してください。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
When initializing StripeClient using StripeClient.builder(), providing a null value for the API key via .setApiKey(null) is allowed by the builder's interface. However, calling .build() on this builder results in an IllegalArgumentException because a global API key is expected at build time.
In a multi-tenant environment, it's common to use a single StripeClient instance and provide the specific tenant's API key with each request using RequestOptions.builder().setApiKey("sk_..."). In such scenarios, a global API key for the StripeClient itself is not necessary and might even be undesirable.
Currently, the SDK mandates a non-null API key during StripeClient construction, even if RequestOptions will be used for every subsequent API call.
To Reproduce
Attempt to build a StripeClient with a null API key:
try {
StripeClient client = StripeClient.builder()
.setApiKey(null) // Explicitly setting null, or not calling setApiKey if it defaults to null internally and is checked
.build();
// Potentially make a call, though the build() itself might fail
// CustomerCollection customers = client.customers().list(RequestOptions.builder().setApiKey("sk_test_specific_tenant").build());
} catch (Exception e) {
e.printStackTrace(); // Observe the exception during build()
}
Expected behavior
It should be possible to construct a StripeClient instance without a globally configured API key (i.e., with apiKey being null or not set on the builder) if the intention is to always provide the API key per request via RequestOptions.
The StripeClient.build() method should not throw an exception if no global API key is provided, and the responsibility for providing the API key should then fall entirely on the RequestOptions for each API call. If an API call is made without an API key in RequestOptions (and no global key is set), then an exception at that point would be appropriate.
Code snippets
OS
macOS
Java version
Java 21
stripe-java version
29.0.0
API version
2025-03-31.basil
Additional context
StripeClientBuilder.setApiKey does handle null apiKey so I don't get it why it's not accepted when the client is build.
https://github.com/stripe/stripe-java/blob/d177cbc62bb595399e298288fe9803c1d213a3ac/src/main/java/com/stripe/StripeClient.java#L519-L526
- 主要言語
- Java
- スター
- 1k
- フォーク
- 406
- 平均マージ
- 2日 18時間
- マージ済み PR(30日)
- 20
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
stripe/stripe-java のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
stripe/stripe-java#2280 · コメント 4 件 ·
-
feature-request future
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
stripe/stripe-java#2024 · コメント 5 件 · リアクション 3 件 ·
-
feature-request future
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
stripe/stripe-java#1964 · コメント 1 件 ·
-
feature-request future
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
stripe/stripe-java#1905 · コメント 7 件 · リアクション 7 件 ·
-
bug future
stripe/stripe-java#1846 · コメント 8 件 · 担当者 1 名 ·
stripe/stripe-java の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
infinispan/infinispan#18150 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
opensearch-project/k-NN#3597 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100