Production was returning HTTP 413 with empty body on the first APPEND segment of every video upload to X v2 — surfacing to users as 'An unknown X error occurred.' Empty-body 413 is the classic signature of an edge/CDN rejection: the X gateway is denying the request before X's application code sees it. The X v2 reference docs say 'max chunk size: 5MB', but every canonical reference uses 1MB: - X's official Python quickstart: `chunk_size = 1024 * 1024` - X's official JavaScript quickstart: `const chunkSize = 1024 * 1024` - twitter-api-v2 (the most-used Node SDK, used by Postiz et al.): `chunkSize: number = 1024 * 1024` 5MB plus multipart-form overhead apparently exceeds an undocumented edge limit. 1MB is the empirically safe size everyone converges on. Changes: - XPublisher chunked APPEND now uses 1MB chunks. An 8MB video uploads as 8 segments instead of 2; more roundtrips but actually succeeds. - Set explicit Content-Type on each chunk attach (matches the simple upload path in the same file). - XPublishException::fromApiResponse maps HTTP 413 to ErrorCategory::MediaFormat with the message 'Media chunk rejected by X (payload too large).' so we don't surface 413 as 'unknown' if it ever recurs. Test: unit test covering the 413→MediaFormat mapping. Full suite green (1503 passed, 2 skipped). |
||
|---|---|---|
| .. | ||
| Ai | ||
| Social | ||
| TokenExpiredException.php | ||