Skip to content

♻️ Improve error 429 management#78

Merged
jbelien merged 1 commit intomasterfrom
fix/429-too-many-requests
Mar 16, 2026
Merged

♻️ Improve error 429 management#78
jbelien merged 1 commit intomasterfrom
fix/429-too-many-requests

Conversation

@jbelien
Copy link
Member

@jbelien jbelien commented Mar 16, 2026

Caution

The code and content of this Pull Request has been generated by @copilot.

This pull request introduces significant improvements to the Wikidata fetching logic in WikidataCommand.php, focusing on better handling of rate limits, retries, and error scenarios. The changes ensure more robust and respectful interaction with the Wikidata API, helping to avoid rate-limiting issues and partial downloads.

Enhancements to request handling and robustness:

  • Introduced request throttling with a minimum interval between requests to reduce the risk of hitting Wikidata rate limits, using the new throttleRequests method and related constants (REQUEST_INTERVAL_MICROSECONDS). [1] [2]
  • Improved retry logic by increasing the maximum number of retries, using a dynamic delay based on the Retry-After header when available, and setting a default retry delay (MAX_RETRIES, DEFAULT_RETRY_DELAY_MILLISECONDS, and retryDelayMilliseconds). [1] [2] [3]

Error handling and cleanup:

  • Enhanced error handling by cleaning up partial downloads when requests fail, and by returning a boolean status from the save method to indicate success or failure. [1] [2] [3]
  • Added handling for general GuzzleException errors, ensuring all error cases are covered and partial files are removed appropriately.

Other improvements:

  • Updated the save method signature and its usage to return a boolean, improving clarity and reliability of file existence checks after download attempts. [1] [2]
  • Added request timeout settings to Guzzle client configuration for more robust network operations.

These changes collectively make the Wikidata fetching process more reliable, respectful of API limits, and easier to maintain.

@jbelien jbelien merged commit 395289a into master Mar 16, 2026
4 checks passed
@jbelien jbelien deleted the fix/429-too-many-requests branch March 16, 2026 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant