fix: respect Shopware Store API 429s during catalog sync - #789
Merged
Conversation
Catalog sync was probing every in-use Shopware version with concurrent en/de locale calls and continuing after failures, which amplified 429 bursts from api.shopware.com. Add Retry-After/backoff on store client GETs, serialize locale probes, and abort remaining versions when rate limited so the job can retry without stomping the API. Co-authored-by: Soner <github@shyim.de>
Contributor
Greptile SummaryThe PR adds bounded 429 retries to the Shopware Store client and serializes catalog locale/version probes so rate limiting stops further fan-out.
Confidence Score: 4/5The PR should not merge until a second-locale 429 preserves the first locale’s successful probe as partial progress. The new de_DE rate-limit branch explicitly returns nil for the already-fetched en_GB result, preventing the partial persistence promised by the sync behavior and forcing redundant full retries. Files Needing Attention: api/internal/catalog/sync/service.go, api/internal/catalog/sync/service_test.go
|
| Filename | Overview |
|---|---|
| api/internal/catalog/sync/service.go | Serializes probes and aborts on rate limiting, but discards a successful English probe when the following German probe returns 429. |
| api/internal/shopwareaccount/retry.go | Adds bounded 429-only retries with Retry-After parsing, capped delays, jitter, response draining, and context-aware sleep. |
| api/internal/shopwareaccount/store.go | Routes PluginsByName through the retry helper and exposes non-success statuses as typed APIError values. |
| api/internal/catalog/sync/service_test.go | Covers serialized requests and version-level aborts, but not an en_GB success followed by a de_DE 429. |
| api/internal/shopwareaccount/retry_test.go | Covers Retry-After, fallback backoff, retry exhaustion, parsing, and immediate handling of non-429 responses. |
Sequence Diagram
sequenceDiagram
participant Sync as Catalog Sync
participant Store as Shopware Store API
participant DB as PostgreSQL
Sync->>Store: Probe en_GB
Store-->>Sync: 200 catalog data
Sync->>Store: Probe de_DE
Store-->>Sync: 429 after retries
Note over Sync: Current branch discards en_GB result
Sync-->>Sync: Abort remaining versions
Note over DB: No partial data persisted when this is the first version
Reviews (1): Last reviewed commit: "fix: respect Store API 429s during catal..." | Re-trigger Greptile
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.
Root cause
Production
shopmon-workerwas burstingapi.shopware.comduring store-extension catalog sync:shopwareaccount.PluginsByName— any non-200 became an immediate error (store api returned status 429) with noRetry-After/ backoff.catalog/sync: every distinct in-use Shopware version was probed, and within each version en_GB + de_DE ran concurrently. On probe failure the sync logged a warn and continued to the next version, so a rate-limit did not stop the stomping — scrapes then redispatched sync for missing compatibility rows.Changes
Store client (
api/internal/shopwareaccount)do()retries HTTP 429 only (other statuses are not blindly retried).Retry-After(delta-seconds or HTTP-date), capped; otherwise exponential backoff with jitter.APIError/IsRateLimitedwhen still failing.Catalog sync (
api/internal/catalog/sync)Verification
mise run lint— passed (API golangci-lint + frontend oxlint/tsc/oxfmt/vitest)mise run test— passed (go test ./internal/...)go test ./internal/shopwareaccount/ ./internal/catalog/sync/