Skip to content

feat: add environment variable validation at build time - #690

Open
TOS1ANO wants to merge 3 commits into
anumukul:mainfrom
TOS1ANO:feat/env-var-build-validation
Open

feat: add environment variable validation at build time#690
TOS1ANO wants to merge 3 commits into
anumukul:mainfrom
TOS1ANO:feat/env-var-build-validation

Conversation

@TOS1ANO

@TOS1ANO TOS1ANO commented Jul 30, 2026

Copy link
Copy Markdown

Linked Issue

Closes #645 [INFRA-37]

What Changed

New: frontend/lib/env-validator.ts

Build-time environment variable validation module that checks:

Variable Validation Format
NEXT_PUBLIC_CONTRACT_ID Required, valid format 56-char string starting with C (Stellar contract ID)
NEXT_PUBLIC_NETWORK Required, recognized value testnet, futurenet, or mainnet
NEXT_PUBLIC_SOROBAN_RPC Required, valid URL Must start with http:// or https://

Features:

  • Network-specific variant resolution: checks _TESTNET, _FUTURENET, _MAINNET suffixes before falling back to base var
  • Cross-field consistency check: warns if network=mainnet but RPC points to a testnet URL
  • Clear, actionable error messages with fix guidance

Modified: frontend/next.config.ts

  • Imports and calls assertEnv() at module load time
  • Fails the build immediately on missing/malformed config
  • Runs during both next build and next dev

Testing

  • TypeScript compilation passes for the two changed files
  • Error scenarios covered: missing vars, malformed contract ID, invalid network, bad RPC URL, network/RPC mismatch

PR Details

Detail Value
Branch feat/env-var-build-validation
Files changed 2 files, +143 lines

TOS1ANO added 3 commits July 30, 2026 14:33
Add get_jobs_batch(start, limit) public view function to smart contract returning Vec<Job>, skipping non-existent IDs safely. Add getJobsBatch() frontend helper. Replace NxgetJob(id) loops with single batch calls on Home, Dashboard, Transactions, Profile, Compare pages and disputes-loader. Fix JSX nesting bugs in layout.tsx and ToastProvider.tsx. Move SSR-disabled dynamic imports into ClientComponents.tsx.
Add configurable max active jobs per user to prevent spam. Default 50. Admin can change via set_max_active_jobs_per_client. Validated in post_job and accept_job. Adds ActiveJobLimitExceeded error (code 15).
Validate NEXT_PUBLIC_CONTRACT_ID, NEXT_PUBLIC_NETWORK, and NEXT_PUBLIC_SOROBAN_RPC at build time via a new env-validator module. Fails early on missing/malformed config. Validates contract ID format (56-char C-prefixed), network name (testnet/futurenet/mainnet), and RPC URL format. Includes network-specific variant resolution and cross-field consistency checks.
@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@TOS1ANO 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! 🚀

Learn more about application limits

@anumukul

anumukul commented Aug 5, 2026

Copy link
Copy Markdown
Owner

@TOS1ANO please resolve conflicts

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.

[INFRA-37] Add environment variable validation at build time

2 participants