Skip to content

#755 createSorokitClient does not validate required config before using it — fails late with cryptic errors - #822

Merged
k-deejah merged 1 commit into
Sorokit:mainfrom
jotel-dev:fix/755-createSorokitClient-config-validation
Oct 18, 2026
Merged

k-deejah merged 1 commit into
Sorokit:mainfrom
jotel-dev:fix/755-createSorokitClient-config-validation

Conversation

@jotel-dev

Copy link
Copy Markdown
Contributor

Summary

Fixes #755

Validates required configuration fields (horizonUrl, rpcUrl, networkPassphrase, and network) in the client constructor / startup validation before binding them to methods. Fails fast with clear, descriptive error messages if required configuration is missing or invalid.

Changes

  • Updated SorokitClientConfig to accept networkPassphrase?: string.
  • Enhanced validateClientConfig to validate networkPassphrase, as well as non-string, malformed, or empty horizonUrl and rpcUrl.
  • Added validation in createSorokitClient for horizonUrl, rpcUrl, and networkPassphrase right before binding them to client methods and assembling ResolvedNetworkConfig.
  • Added comprehensive unit tests in src/tests/client.test.ts covering missing and invalid configuration scenarios.

Fields Validated in Constructor

  • network: must be one of "mainnet" | "testnet" | "futurenet".
  • horizonUrl: must be a valid HTTP/HTTPS URL string.
  • rpcUrl: must be a valid HTTP/HTTPS URL string.
  • networkPassphrase: must be a non-empty string.
  • Endpoint lists (horizonEndpoints, rpcEndpoints): validated via validateEndpointList.
  • Optional interfaces: logger, cache, errorHandler, errorCodeTransformer, logLevel, maxTxPerSecond, timeoutMs, defaultTimeoutMs, deviceTrustThreshold, sorobanPoll.

@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@jotel-dev 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

@k-deejah
k-deejah merged commit 25923d6 into Sorokit:main Oct 18, 2026
4 of 5 checks passed
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.

createSorokitClient does not validate required config before using it — fails late with cryptic errors

2 participants