feat: add startup config validation for Soroban environment (#72)#112
Merged
ritik4ever merged 2 commits intoritik4ever:mainfrom Mar 29, 2026
Merged
Conversation
…er#72) - Validate CONTRACT_ID and SERVER_PRIVATE_KEY at startup - Fail fast with helpful error messages for invalid config - Support SOROBAN_DISABLED=true for local development - Distinguish between required and optional environment variables - Add comprehensive test suite with 30+ test cases - Update README section 8 with validation behavior documentation - All acceptance criteria met
|
Someone is attempting to deploy a commit to the ritik4ever's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@cyber-excel10 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Closes #72
Description
This PR implements startup configuration validation for the Soroban environment, addressing issue #72.
When the backend starts, it now validates all Soroban-related environment variables immediately and fails fast with helpful error messages if config is invalid. This prevents silent failures and makes debugging easier.
Type of Change
Changes Made
Backend
backend/src/config/validateEnv.ts— Zod-based validation for all environment variablesCONTRACT_ID(56 chars, starts with C) andSERVER_PRIVATE_KEY(56 chars, starts with S)SOROBAN_DISABLED=trueflag for local development without on-chain configValidatedConfiginterface with all validated settingsprocess.exit(1)on validation failure with descriptive error messagesTesting
backend/src/config/validateEnv.test.ts— 30+ test cases using vitestbackend/test-validateEnv.js— Manual test guide with 10 scenariosDocumentation
README.mdsection 8 with validation behavior and startup config detailsSOROBAN_DISABLEDmode for local developmentAcceptance Criteria
Testing Instructions
Run Unit Tests
Manual Testing
cd backend node test-validateEnv.jsThis displays all 10 test scenarios with expected behaviors.
Test Scenarios Covered
SOROBAN_DISABLED=true✅CONTRACT_IDwhen Soroban enabled ❌SERVER_PRIVATE_KEYwhen Soroban enabled ❌CONTRACT_IDformat ❌SERVER_PRIVATE_KEYformat ❌PORTparsing ✅PORT❌ALLOWED_ASSETS✅RPC_URL❌Verification Checklist
Notes
TypeScript warnings about missing
vitestand@types/nodeare just IDE hints they will resolve after runningnpm installThe validation runs at startup before any routes are initialized
validateEnv()is called inbackend/src/index.tsline 408All defaults match README section 8 specifications