Skip to content

feat: add configurable request timeout to the Creators API - #154

Merged
sergioteula merged 1 commit into
masterfrom
claude/pr-review-management-xmss8r
Sep 3, 2026
Merged

feat: add configurable request timeout to the Creators API#154
sergioteula merged 1 commit into
masterfrom
claude/pr-review-management-xmss8r

Conversation

@sergioteula

Copy link
Copy Markdown
Owner

Supersedes #151. Same feature, rebased onto master (7.0.0) and with the points raised while reviewing that PR applied. Original work by @YPCrumble, authorship preserved on the commit.

What it does

Adds a timeout parameter to AmazonCreatorsApi and AsyncAmazonCreatorsApi, defaulting to 30 seconds, with None to wait indefinitely. The sync client previously had no timeout at all, so a stalled connection to Amazon could hold a worker forever; it now matches what the async client already did.

Changes over #151

  • Rebased onto 7.0.0 and renumbered to 7.1.0 (pyproject.toml, docs/conf.py, CHANGELOG.md). The original branch targeted 6.4.0, which conflicted after the 6.4.0 and 7.0.0 releases.
  • Feeds and reports covered too. list_feeds, get_feed, list_reports and get_report landed after the original branch was written and were not forwarding _request_timeout, so the timeout applied to only half the methods.
  • Async token refresh honours the timeout. AsyncOAuth2TokenManager built its httpx.AsyncClient with no arguments, so token refresh always used the 5 second httpx default regardless of the configured value. It now takes the same timeout as the API requests.
  • Zero and negative timeouts are rejected with InvalidArgumentError at construction. Previously they reached the bundled SDK, where _request_timeout is annotated gt=0, and surfaced as a raw pydantic ValidationError in the sync client while failing instantly in the async one.
  • Wording corrected. The original changelog entry claimed requests would no longer wait indefinitely; that is true for API requests but not for the sync OAuth2 token refresh, which creatorsapi_python_sdk performs with a bare requests.post and no timeout. The entry now says "API requests", and the README and usage guide state what the value does and does not cover.

Known limitation

The sync token refresh remains unbounded. Fixing it means either patching the bundled SDK, which the repo otherwise keeps untouched, or giving the sync client its own token manager the way amazon_creatorsapi.aio already has. Left out of this PR deliberately — happy to follow up whichever way you prefer.

Verification

uv run pre-commit run -a passes in full: ruff format, ruff check, mypy, the test suite and the version consistency check. 160 passed, 47 skipped (integration tests, no credentials), coverage 98.76% against the 98% floor.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JvKfVvJqdCZnPfNaNP2fT5


Generated by Claude Code

Rebase of #151 onto master (7.0.0) with the adjustments raised in review:

- Bump to 7.1.0 in pyproject.toml, docs/conf.py and CHANGELOG.md
- Forward the timeout in list_feeds, get_feed, list_reports and get_report,
  added after the original branch was written
- Apply the timeout to the async OAuth2 token refresh, which always used the
  5 second default from httpx
- Reject timeouts of zero or below with InvalidArgumentError instead of
  surfacing a validation error from the bundled SDK
- Document that the sync token refresh is handled by the bundled SDK and is
  not covered by this value

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JvKfVvJqdCZnPfNaNP2fT5
@sergioteula
sergioteula merged commit 8bb8ebc into master Sep 3, 2026
8 checks passed
@sergioteula
sergioteula deleted the claude/pr-review-management-xmss8r branch September 3, 2026 22:52
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.

2 participants