Skip to content

fix(providers): treat empty Retry-After header as no hint#91

Merged
hqhq1025 merged 1 commit intomainfrom
wt/loop-fix-retry-after-empty
Apr 19, 2026
Merged

fix(providers): treat empty Retry-After header as no hint#91
hqhq1025 merged 1 commit intomainfrom
wt/loop-fix-retry-after-empty

Conversation

@hqhq1025
Copy link
Copy Markdown
Collaborator

Summary

  • extractRetryAfterMs was passing the raw header to Number(...), so an empty/whitespace-only Retry-After coerced to 0 and emitted a misleading retryAfterMs=0 hint to onRetry callbacks (downstream buildRetryInfo clamps to backoff so behavior wasn't catastrophic, but the signal was wrong).
  • Reject empty / whitespace strings, gate the seconds path on a numeric-only regex, and fall through to Date.parse for HTTP-date Retry-After values.

Changes

  • packages/providers/src/retry.ts — guard empty/whitespace input, numeric regex before Number(...).
  • packages/providers/src/retry.test.ts — three new tests: empty header, whitespace-only header, HTTP-date header.

PRINCIPLES check

  • Compatibility: no API/contract change.
  • Upgradeability: pure function, no schema impact.
  • No bloat: same module, +0 deps.
  • Elegance: removes a silent footgun.

Test plan

  • pnpm --filter @open-codesign/providers test — 39 passed (was 36).
  • pnpm --filter @open-codesign/providers typecheck.
  • pnpm exec biome check packages/providers/src/retry.ts packages/providers/src/retry.test.ts.

Number('') and Number('   ') coerce to 0, so an empty or whitespace-only
Retry-After header was being read as a 0 ms hint. The downstream
buildRetryInfo guards against zero by Math.max'ing against the backoff,
so behavior was not catastrophic, but the classifier was emitting a
misleading retryAfterMs=0 that surfaced via onRetry callbacks.

Reject empty strings up front, gate the seconds path on a numeric-only
regex, and let HTTP-date Retry-After values fall through to Date.parse.

Adds three tests covering empty, whitespace, and HTTP-date cases.
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • No high-confidence issues found in the modified lines.

Summary

  • Review mode: initial
  • No issues identified in this diff.
  • Constraint check on modified lines: no direct provider SDK imports, no new dependencies/licenses, no hardcoded UI tokens, and no silent fallback introduced.
  • Not found in repo/docs: docs/VISION.md, docs/PRINCIPLES.md (repository note indicates internal/gitignored docs), so full policy cross-check against those files could not be completed from this checkout.
  • Residual risk/testing gap: HTTP-date parsing test is time-window based and may be flaky under heavy CI clock skew; no deterministic time-mocking in added tests.

Testing

  • Not run (automation)

open-codesign Bot

@hqhq1025 hqhq1025 merged commit 6d2eab2 into main Apr 19, 2026
5 of 6 checks passed
@hqhq1025 hqhq1025 deleted the wt/loop-fix-retry-after-empty branch April 19, 2026 06:15
@hqhq1025 hqhq1025 mentioned this pull request Apr 19, 2026
4 tasks
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.

1 participant