Skip to content

Conversation

@elnafateh
Copy link
Contributor

@elnafateh elnafateh commented Sep 14, 2025

Why?

BearerTokenAuthenticator threw an IllegalArgumentException with a vague message when given a null API key. This was inconsistent with the rest of the SDK.

What?

  • Throw ApiKeyMissingException instead
  • Improve the message to: "API key cannot be null. Set Stripe.apiKey"

Notes

  • This is an intentionally minimal and backward-compatible change.

Future Work

A possible improvement for multi-tenant environments would be allowing StripeClient construction without requiring a global API key, instead relying solely on RequestOptions for per-request keys.

Changelog

  • ⚠️ throw ApiKeyMissingException instead of IllegalArgumentException when making a request before setting an API key initializing a client without an API key. Tweak the wording of that message to better indicate how to fix.

@elnafateh elnafateh requested a review from a team as a code owner September 14, 2025 13:26
@elnafateh elnafateh requested review from xavdid-stripe and removed request for a team September 14, 2025 13:26
@cla-assistant
Copy link

cla-assistant bot commented Sep 14, 2025

CLA assistant check
All committers have signed the CLA.

@xavdid-stripe
Copy link
Member

xavdid-stripe commented Sep 17, 2025

@elnafateh this looks good! you need to sign the CLA (see above comment) and then I can get it merged.

@elnafateh
Copy link
Contributor Author

@xavdid-stripe it's done

@xavdid-stripe xavdid-stripe enabled auto-merge (squash) September 18, 2025 17:37
@xavdid-stripe xavdid-stripe changed the title fix: clarify exception message when API key is null Throw ApiKeyMissingException instead of IllegalArgumentException for unset API keys Sep 18, 2025
@xavdid-stripe xavdid-stripe merged commit ea0da3a into stripe:master Sep 18, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants