Skip to content

fix: distinguish EasyEDA HTTP 403 rate limiting from component lookup failure - #412

Merged
seveibar merged 1 commit into
tscircuit:mainfrom
Hero988:fix/distinguish-403-rate-limit-409
Jul 23, 2026
Merged

fix: distinguish EasyEDA HTTP 403 rate limiting from component lookup failure#412
seveibar merged 1 commit into
tscircuit:mainfrom
Hero988:fix/distinguish-403-rate-limit-409

Conversation

@Hero988

@Hero988 Hero988 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Fixes #409 — the error-text distinction (suggestion 3 of the issue).

Problem

EasyEDA's component API rate-limits by IP and answers HTTP 403 once tripped (not 429, no Retry-After). fetchEasyEDAComponent treated any non-success response as a lookup failure, so a throttled batch surfaced as:

Error: Failed to search for the component

which points the user at the part number. The part is fine; the request was throttled — as measured in #409, every LCSC id 403s identically mid-cooldown and recovers after ~2 minutes.

Change (minimal, one concern)

  • A 403 on either the search request or the component-details request now throws a rate-limit-specific error naming the part, stating it's an IP-based limit, and giving the ~2 minute cooldown hint from the issue's measurements.
  • Other non-success statuses keep their existing messages but now include the HTTP status code.
  • Component not found (successful response, empty result list) is unchanged — it stays distinct from rate limiting, which is the core complaint in EasyEDA rate-limits with HTTP 403; surfaced as "Failed to search for the component" #409.

Retry/backoff, serialising the parts-engine batch, and CDN proxying (suggestions 1, 2, 4) are deliberately left as follow-ups — they're behaviour/architecture decisions, and per review feedback on other PRs I'm keeping one change per PR.

Tests (red→green)

tests/fetch-tests/rate-limit-403.test.ts — uses the existing injectable fetch option, so no network (unlike the live-API fetch tests, these can't themselves be rate-limited):

  1. search-request 403 → /rate limit/i error (was: generic lookup failure) — red before, green after
  2. component-details 403 → /rate limit/i error — red before, green after
  3. empty search result → still exactly Component not found (guards the distinction)
  4. non-403 failure (500) → message includes HTTP 500red before, green after

bun test on the new file: 4 pass. tsc --noEmit clean. biome check clean.

Note: #393 (May) adds part numbers to these messages but doesn't distinguish status codes; this PR is orthogonal and touches only the status-code branches.

… failure

EasyEDA's component API rate-limits by IP and answers HTTP 403 once
tripped. fetchEasyEDAComponent treated any non-success response as a
lookup failure, so throttled batches surfaced as 'Failed to search for
the component', sending users hunting for a nonexistent part-number
problem.

Now a 403 on either the search or the component-details request throws
a rate-limit-specific error (with the ~2 minute cooldown hint), and
other non-success statuses include the HTTP status code. 'Component not
found' remains unchanged and distinct.

Fixes tscircuit#409 (error-text distinction; retry/serialisation/proxying left
as follow-ups)
@seveibar
seveibar merged commit 27349ad into tscircuit:main Jul 23, 2026
5 checks passed
@tscircuitbot

Copy link
Copy Markdown

Thank you for your contribution! 🎉

PR Rating:
Impact: Tiny

Track your contributions and see the leaderboard at: tscircuit Contribution Tracker


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.

EasyEDA rate-limits with HTTP 403; surfaced as "Failed to search for the component"

3 participants