gitroomhq/postiz-app · error · BadBody
Reddit media upload did not return a location
Error message
Reddit media upload did not return a location
What it means
RedditProvider.uploadFileToReddit parses the S3 upload-part XML returned by Reddit's upload lease endpoint for a <Location> tag; when none is found it throws this BadBody with the raw response. Without the Location the multipart upload target is unknown, so the media upload cannot proceed.
Source
Thrown at libraries/nestjs-libraries/src/integrations/social/reddit.provider.ts:240
upload.append('file', stream, {
filename: path.split('/').pop(),
contentType: (mimeType as string) || 'application/octet-stream',
knownLength: fileSize,
});
const d = await this.getSsrfSafeAxios().post('https:' + action, upload, {
headers: upload.getHeaders(),
});
// S3 only echoes a <Location> body when the POST succeeds with 201; guard
// the parse so an empty/unexpected body fails with a clear error instead
// of a TypeError.
const location = [
...String(d.data || '').matchAll(/<Location>(.*?)<\/Location>/g),
][0]?.[1];
if (!location) {
throw new BadBody(
this.identifier,
String(d.data || '{}'),
Buffer.from('{}'),
'Reddit media upload did not return a location'
);
}
return location;
}
// Read-only recovery of a submission: the submit endpoint answers media
// posts with only a websocket url, and an interrupted activity may have
// submitted without us seeing the response - the user's newest submissions
// answer both cases without ever re-submitting.
private async findSubmittedPost(
accessToken: string,
username: string,
sr: string,View on GitHub (pinned to 0f1647f749)
Solutions
- Inspect the raw body included in the error (d.data) to see what Reddit actually returned
- Re-authenticate the Reddit integration (expired tokens often yield error JSON)
- Confirm the media mimetype is supported for Reddit uploads
- Check Reddit API status / version for upload lease contract changes
Defensive patterns
Strategy: try-catch
Try / catch
catch (e) { if (e instanceof BadBody && /did not return a location/.test(e.message)) { /* log d.data body, re-auth */ } } Prevention
- Check auth freshness before media uploads to Reddit
- Log the raw lease response for contract drift
When it happens
Trigger: Reddit's api/media/asset endpoint returns a body without <Location>...</Location> — expired lease, unexpected error JSON, or Reddit API change; also when d.data is empty.
Common situations: Auth/session issues making Reddit return an error body instead of the lease XML, Reddit API contract change, or mimetype not covered by the asset lease.
Related errors
- Reddit rejected the post to r/${postData.sr}: ${all.json.err
- Reddit took too long to answer, please check your account be
- Failed to fetch media: ${fileResponse.statusText}
- Failed to upload the media file
- Could not determine the media size for upload
AI-assisted analysis of gitroomhq/postiz-app@0f1647f749 (2026-08-27).
Data as JSON: /api/errors/61509914bd3df335.
Report an issue: GitHub.