{"record":{"id":"61509914bd3df335","repo":"gitroomhq/postiz-app","slug":"reddit-media-upload-did-not-return-a-location","errorCode":null,"errorMessage":"Reddit media upload did not return a location","messagePattern":"Reddit media upload did not return a location","errorType":"exception","errorClass":"BadBody","httpStatus":null,"severity":"error","filePath":"libraries/nestjs-libraries/src/integrations/social/reddit.provider.ts","lineNumber":240,"sourceCode":"\n    upload.append('file', stream, {\n      filename: path.split('/').pop(),\n      contentType: (mimeType as string) || 'application/octet-stream',\n      knownLength: fileSize,\n    });\n\n    const d = await this.getSsrfSafeAxios().post('https:' + action, upload, {\n      headers: upload.getHeaders(),\n    });\n\n    // S3 only echoes a <Location> body when the POST succeeds with 201; guard\n    // the parse so an empty/unexpected body fails with a clear error instead\n    // of a TypeError.\n    const location = [\n      ...String(d.data || '').matchAll(/<Location>(.*?)<\\/Location>/g),\n    ][0]?.[1];\n    if (!location) {\n      throw new BadBody(\n        this.identifier,\n        String(d.data || '{}'),\n        Buffer.from('{}'),\n        'Reddit media upload did not return a location'\n      );\n    }\n\n    return location;\n  }\n\n  // Read-only recovery of a submission: the submit endpoint answers media\n  // posts with only a websocket url, and an interrupted activity may have\n  // submitted without us seeing the response - the user's newest submissions\n  // answer both cases without ever re-submitting.\n  private async findSubmittedPost(\n    accessToken: string,\n    username: string,\n    sr: string,","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/gitroomhq/postiz-app/blob/0f1647f7491a217d43eb5ae7a480484bdf0aff3e/libraries/nestjs-libraries/src/integrations/social/reddit.provider.ts#L222-L258","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (e) { if (e instanceof BadBody && /did not return a location/.test(e.message)) { /* log d.data body, re-auth */ } }","preventionTips":["Check auth freshness before media uploads to Reddit","Log the raw lease response for contract drift"],"tags":["reddit","media-upload","xml-parse"],"backgroundTag":"media-upload-failed","analyzedSha":"0f1647f7491a217d43eb5ae7a480484bdf0aff3e","analyzedAt":"2026-08-27T12:09:55.020Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}