feat: validate client config on construction#36
Merged
Lakes41 merged 1 commit intoJun 16, 2026
Conversation
- Add validateConfig helper in sdkConfig.ts - Throw GuildPassError(INVALID_CONFIG) for missing/invalid apiUrl - Throw GuildPassError(INVALID_CONFIG) for non-positive timeoutMs - Call validateConfig at the top of GuildPassClient constructor - Add test suite covering all invalid and valid config cases Closes Adamantine-guild#21
5 tasks
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.
Description
Adds early config validation to GuildPassClient so invalid values throw a
clear GuildPassError at construction time instead of causing confusing
errors later inside HttpClient or fetch.
Semver impact: patch
Linked Issue
Closes #21
Type of Change
Changes Made
apiUrl is a non-empty absolute http/https URL and timeoutMs (when provided)
is a positive number
validateConfig(config) at the top of the constructor, before merging
defaults
covering all acceptance criteria (empty apiUrl, invalid URL, timeoutMs: 0,
negative timeoutMs, and a valid config)
Public API Changes
typescript
// src/config/sdkConfig.ts
export function validateConfig(config: GuildPassClientConfig): void
No existing exports changed. No new exported types.
Test Evidence
pnpm test:run
Test Files 6 passed (6)
Tests 25 passed (25)
Duration 1.79s
Build Evidence
pnpm build
CJS dist/index.js 6.00 KB
CJS ⚡️ Build success in 588ms
ESM dist/index.mjs 5.90 KB
ESM ⚡️ Build success in 590ms
DTS dist/index.d.ts 8.79 KB
DTS ⚡️ Build success in 3389ms
Checklist
Additional Notes
chainId is intentionally not validated against SUPPORTED_NETWORKS per the
issue notes — unsupported chains are allowed unless maintainers decide
otherwise.