Skip to content

fix(stripe): correct Stripe secret environment variable typo#5

Draft
Yuankai619 wants to merge 1 commit into
demofrom
corvo/fix/stripe-channel-secret-typo-0o85rqs
Draft

fix(stripe): correct Stripe secret environment variable typo#5
Yuankai619 wants to merge 1 commit into
demofrom
corvo/fix/stripe-channel-secret-typo-0o85rqs

Conversation

@Yuankai619
Copy link
Copy Markdown
Member

What does this PR do?

This PR corrects a spelling typo in the Stripe API secret key environment variable name. It changes process.env.Stripe_CHANEL_SECRET (with one 'L') to process.env.Stripe_CHANNEL_SECRET (with two 'L's) in both the Stripe client helper initialization (lib/stripe.ts) and the mock key check inside the payment API endpoint (app/api/checkout/payment/route.ts).

Why is this change needed?

At runtime, the Stripe initialization failed with the error Neither apiKey nor config.authenticator provided because the deployed environment variable on Cloud Run is named Stripe_CHANNEL_SECRET. Since the code was looking for Stripe_CHANEL_SECRET, it received undefined, causing the Stripe client instantiation to fail.

  • Incident: 0.o85rqsbrm37a
  • Alert: Ticket flow error alert(dev)
  • Triggered at: 2026-05-22T17:19:16.000Z
  • Root cause: Typo in variable name Stripe_CHANEL_SECRET (should be Stripe_CHANNEL_SECRET) resulting in a failure to initialize Stripe client.

How was this change tested?

  • Manual diff and environment variable verification on Cloud Run config.
  • Verified correct spelling matches .env.production.example and deployment pipeline configs.

What should reviewers focus on?

Reviewers should verify that the correct environment variable name on other deployment targets or local .env is indeed Stripe_CHANNEL_SECRET to ensure compatibility.

Out of scope

No structural changes or payment logic changes were introduced.

Generated by

🤖 Corvo Agent — investigation traced to commit 750e214e131e5d5547d15c51b7c11981840f1a52e5e63293ef14b458aadeac24a0ac83f8f1737ce87a801368bf0bbe0cf8a18684d3ecad9532a9bbd53d62fc1ae51cd07f2bc403426c8f2026b9ebc0e6aa5bf00 (which introduced the Stripe_CHANEL_SECRET spelling).

The Stripe initialization and mock key check were using process.env.Stripe_CHANEL_SECRET instead of process.env.Stripe_CHANNEL_SECRET. This spelling error caused the Stripe client to fail initialization with 'Neither apiKey nor config.authenticator provided' errors at runtime because the correct environment variable name deployed on Cloud Run contains two 'L's (Stripe_CHANNEL_SECRET). This commit corrects the spelling in both files.

Co-Authored-By: Corvo Agent <noreply@corvo.dev>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request corrects a typo in the environment variable name Stripe_CHANNEL_SECRET across the payment route and Stripe library. The reviewer suggests improving the error handling in lib/stripe.ts by replacing the non-null assertion with an explicit check and a descriptive error message to prevent cryptic runtime errors if the environment variable is missing.

Comment thread lib/stripe.ts
export function getStripe(): Stripe {
if (!_stripe) {
const stripeSecretKey = process.env.Stripe_CHANEL_SECRET;
const stripeSecretKey = process.env.Stripe_CHANNEL_SECRET;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While correcting the typo is necessary, relying on a non-null assertion (!) for environment variables can lead to cryptic runtime errors if the variable is missing. Adding an explicit check ensures a clearer error message, which would have helped identify the issue described in the PR more quickly.

Suggested change
const stripeSecretKey = process.env.Stripe_CHANNEL_SECRET;
const stripeSecretKey = process.env.Stripe_CHANNEL_SECRET;
if (!stripeSecretKey) {
throw new Error('Missing Stripe_CHANNEL_SECRET environment variable');
}
References
  1. Ensure appropriate null/nil/None checks or other language-idiomatic guards exist before object property accesses or using values that are expected to be present.

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.

1 participant