fix: handle empty publicStripeKey to prevent frontend crash (#5640) Additional changes#5641
Open
iroussos25 wants to merge 7 commits intoNangoHQ:masterfrom
Open
fix: handle empty publicStripeKey to prevent frontend crash (#5640) Additional changes#5641iroussos25 wants to merge 7 commits intoNangoHQ:masterfrom
iroussos25 wants to merge 7 commits intoNangoHQ:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Review found no issues; changes appear appropriate and stable.
Status: No Issues Found | Risk: Low
Review Details
📁 5 files reviewed | 💬 0 comments
Instruction Files
└── .claude/
├── agents/
│ └── nango-docs-migrator.md
└── skills/
├── agent-builder-skill/
│ ├── EXAMPLES.md
│ └── SKILL.md
├── creating-integration-docs/
│ └── SKILL.md
└── creating-skills-skill/
└── SKILL.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Problem
Self-hosted instances were experiencing hard process exits during both the frontend hydration and backend initialization phases. This was caused by the unsafe use of non-null assertions (!) and the Stripe SDK attempting to initialize with empty strings or undefined values when environment variables were missing.
The Fix
I have implemented a defense-in-depth approach to ensure Nango remains stable even if Stripe credentials are not provided.
Key Changes:
Backend (Runtime Guard): Replaced unsafe non-null assertions in the Stripe service. The backend now performs a runtime check for STRIPE_SECRET_KEY before instantiation, preventing unhandled exceptions that lead to container crash-loops.
Frontend (SDK Guard): Updated the Webapp utility to conditionally load the Stripe SDK only when a valid publishable key is present. If missing, the promise resolves to null gracefully.
Environment Sanitization: Modified getEnvJs and the WindowEnv interface to sanitize empty environment strings to undefined, providing a predictable data flow for configuration.
UI Resilience: Added a defensive check in the billing upgrade flow to handle "Stripe Unavailable" states, ensuring the user is met with a handled UI state rather than a blank screen/crash.
Scope Note
This PR is strictly focused on environment handling and Stripe stability. It does not include unrelated workspace configuration changes.
Closes #5640
P.S. I’ve recently applied for the Software Engineering role (Giannis Roussos). While setting up my local environment and diving into the docs, I noticed this friction point for self-hosted users and figured a PR was the best way to introduce my engineering style to the team.
This PR adds guards around Stripe initialization and usage to prevent crashes when Stripe environment variables are missing in self-hosted deployments. It replaces a non-null assertion with a runtime check on the backend, conditionally loads the Stripe SDK on the frontend, and updates the environment payload typing to allow undefined Stripe keys.
It also adds a UI-level fallback in the billing upgrade flow to show an error toast when Stripe is unavailable instead of proceeding with a null Stripe instance.
This summary was automatically generated by @propel-code-bot