Skip to content

fix: Add API Key Validation to ThinkingReplayService#2076

Merged
SatyamPandey-07 merged 1 commit into
Eshajha19:mainfrom
zaibamachhaliya:feature/add-api-key-validation-thinking-replay
Jul 10, 2026
Merged

fix: Add API Key Validation to ThinkingReplayService#2076
SatyamPandey-07 merged 1 commit into
Eshajha19:mainfrom
zaibamachhaliya:feature/add-api-key-validation-thinking-replay

Conversation

@zaibamachhaliya

Copy link
Copy Markdown
Contributor

🔍 Issue

Fixes #2051 - ThinkingReplayService Crashes When OPENAI_API_KEY is Missing

✅ What's Changed

Problem

ThinkingReplayService initializes OpenAI client without validating if OPENAI_API_KEY exists in environment variables. When the key is missing, the service crashes with cryptic errors causing the entire application to fail.

Solution

Added API key validation in the constructor with clear error message.

Changes

  • Added OPENAI_API_KEY validation in constructor
  • Throw clear error: "OPENAI_API_KEY is required. Please set it in .env file."
  • Added console.error for debugging
  • Service now fails gracefully with meaningful error

Code Changes

constructor() {
  if (!process.env.OPENAI_API_KEY) {
    console.error('OPENAI_API_KEY is missing from environment variables.');
    throw new Error('OPENAI_API_KEY is required. Please set it in .env file.');
  }

  this.openai = new OpenAI({
    apiKey: process.env.OPENAI_API_KEY
  });
}

@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown

@zaibamachhaliya is attempting to deploy a commit to the eshajha19's projects Team on Vercel.

A member of the Team first needs to authorize it.

@netlify

netlify Bot commented Jul 10, 2026

Copy link
Copy Markdown

Deploy Preview for algo-infinity-verse ready!

Name Link
🔨 Latest commit 3b51c43
🔍 Latest deploy log https://app.netlify.com/projects/algo-infinity-verse/deploys/6a50a547a3109e000848dc83
😎 Deploy Preview https://deploy-preview-2076--algo-infinity-verse.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

Copy link
Copy Markdown

🎉 Thank you for opening this Pull Request!

We appreciate your contribution and effort toward improving this project.

A maintainer will review your PR soon.

Please ensure:
✅ Code follows project guidelines
✅ Changes are properly tested
✅ No sensitive data or API keys are exposed

Thank you for contributing to the community.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@zaibamachhaliya, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 43 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a7687dfb-31db-4077-8e30-e0dfcd073959

📥 Commits

Reviewing files that changed from the base of the PR and between f785512 and 3b51c43.

📒 Files selected for processing (1)
  • backend/services/thinkingReplayService.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added bug Something isn't working SSoC26 labels Jul 10, 2026
@zaibamachhaliya

Copy link
Copy Markdown
Contributor Author

Hi @Eshajha19 please review my pr

@SatyamPandey-07 SatyamPandey-07 added the Medium 30 Points label Jul 10, 2026
@SatyamPandey-07 SatyamPandey-07 merged commit 04440eb into Eshajha19:main Jul 10, 2026
7 of 8 checks passed
@zaibamachhaliya zaibamachhaliya deleted the feature/add-api-key-validation-thinking-replay branch July 10, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Medium 30 Points SSoC26

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ThinkingReplayService Crashes When OPENAI_API_KEY is Missing

2 participants