Skip to content

Validate client configuration at construction time #21

Description

@Lakes41

Summary

Fail fast when GuildPassClient is constructed with invalid configuration values.

Current Behaviour

GuildPassClient merges user config with defaults, but does not validate values such as apiUrl or timeoutMs. Invalid configuration can cause confusing runtime errors later, often inside HttpClient or fetch.

Expected Behaviour

Invalid client configuration should throw a clear GuildPassError during construction.

Suggested Implementation

Add a config validation helper that checks required and optional values. At minimum, validate that apiUrl is a non-empty absolute URL and timeoutMs, when provided, is a positive number.

Files or Areas Likely Affected

  • src/client/GuildPassClient.ts
  • src/config/sdkConfig.ts
  • src/errors/errorCodes.ts
  • tests/client.test.ts

Acceptance Criteria

  • Missing or empty apiUrl throws a clear SDK error
  • Invalid URL strings throw a clear SDK error
  • Non-positive timeoutMs values throw a clear SDK error
  • Valid existing configuration continues to work
  • Tests cover valid and invalid config cases

Additional Notes

Avoid restricting chainId to the current SUPPORTED_NETWORKS list unless maintainers confirm that unsupported chains should be rejected.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignbugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions