Skip to content

Fix: Validate retry configuration at client and request level#104

Open
zeke-codes wants to merge 2 commits into
Adamantine-guild:mainfrom
zeke-codes:fix-retry-validation
Open

Fix: Validate retry configuration at client and request level#104
zeke-codes wants to merge 2 commits into
Adamantine-guild:mainfrom
zeke-codes:fix-retry-validation

Conversation

@zeke-codes

Copy link
Copy Markdown

Description

Added fail-fast validation for retry configuration at both SDK config level and HTTP client level.
This ensures invalid retry settings (negative retries, invalid delays, maxDelay < baseDelay, and invalid retryable status arrays) are rejected early with a clear GuildPassError, preventing silent retry misbehavior or infinite retry loops.

Semver impact: patch

Linked Issue

Closes #57

Type of Change

  • 🐛 Bug fix (patch)
  • ✨ New feature / method (minor)
  • 💥 Breaking change (major)
  • 📝 Documentation / TypeDoc update
  • 🔧 Chore / refactor
  • 🧪 Tests only

Changes Made

  • Added retry configuration validation in validateConfig (src/config/sdkConfig.ts)
  • Added fail-fast retry validation in resolveRetry (src/http/httpClient.ts)
  • Fixed unused variable lint error in src/client/GuildPassClient.ts (_apiKey)
  • Validated:
    • maxRetries is non-negative and finite
    • baseDelayMs and maxDelayMs are non-negative and finite
    • maxDelayMs cannot be less than baseDelayMs
    • retryableStatuses must be a valid non-empty numeric array
  • Ensured invalid retry configs throw GuildPassError before requests are made

Public API Changes

None

Test Evidence

npm run lint: 1 error (fixed apiKey issue + remaining warnings unrelated to this PR)
npm run test: all tests passing

Build Evidence

npm run build: succeeded (no errors)

Checklist

  • I have read CONTRIBUTING.md
  • This PR is linked to an open issue
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test:run passes — all tests green
  • pnpm build succeeds — dist/ generated cleanly
  • All new public methods/types have TypeDoc comments
  • New behaviour is covered by at least one Vitest unit test
  • No new runtime dependencies added without prior maintainer approval
  • docs/ updated if public API changed
  • examples/ updated if new usage patterns were added
  • Backwards compatibility maintained (or breaking change clearly noted above)

Additional Notes

This change focuses on defensive validation of retry configuration to ensure deterministic and safe retry behavior across both SDK-level and request-level configurations.

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.

Validate retry configuration values

1 participant