Skip to content

Fix multipart encoding, pagination rate-limit retry, and API error reporting#133

Merged
bpepple merged 4 commits intomainfrom
dev
May 1, 2026
Merged

Fix multipart encoding, pagination rate-limit retry, and API error reporting#133
bpepple merged 4 commits intomainfrom
dev

Conversation

@bpepple
Copy link
Copy Markdown
Member

@bpepple bpepple commented Apr 26, 2026

Summary

  • Multipart encoding: Only use multipart/form-data for endpoints that have an image field (creator, issue, team, character, arc). Endpoints without an image field (series, universe, etc.) now correctly send JSON, preserving null values and nested objects. Also strips None values from multipart payloads, which can't be represented in form data.
  • Pagination rate-limit retry: When a rate limit error occurs mid-pagination, retry the current page after the specified cooldown instead of propagating the error and forcing the caller to restart the entire fetch from page 1.
  • Improved error messages: Include the response body in ApiError messages to make HTTP errors easier to diagnose.

Endpoints that support file uploads (e.g. creator, issue) require multipart/form-data even when no file is present. Previously, mokkari fell back to JSON when no image file was attached, causing a 415 Unsupported Media Type error. Now all object payloads use form data, with None values stripped and nested dicts JSON-encoded as strings.
@bpepple bpepple self-assigned this Apr 26, 2026
@bpepple bpepple added the bug Something isn't working label Apr 26, 2026
bpepple and others added 3 commits April 30, 2026 08:49
When a RateLimitError occurs mid-pagination, sleep for the retry_after duration (plus a small buffer) and retry the current page rather than bubbling the error up and forcing the caller to restart the entire paginated fetch from the beginning.

Co-authored-by: Copilot <copilot@github.com>
Endpoints without an image field (e.g. series, universe) require JSON, while endpoints with an image field (creator, issue, team, character, arc) require multipart/form-data even when no file is uploaded.
@bpepple bpepple changed the title Always use multipart/form-data for object payloads Fix multipart encoding, pagination rate-limit retry, and API error reporting May 1, 2026
@bpepple bpepple merged commit 987a73d into main May 1, 2026
11 checks passed
@bpepple bpepple deleted the dev branch May 1, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant