{"record":{"id":"fb476d641b04f467","repo":"conductor-oss/conductor","slug":"openai-video-download-failed-with-status-d-s","errorCode":null,"errorMessage":"OpenAI Video download failed with status %d: %s","messagePattern":"OpenAI Video download failed with status (.+?): (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/org/conductoross/conductor/ai/providers/openai/api/OpenAIVideoApi.java","lineNumber":170,"sourceCode":"     * consume the stream. The stream wrapper closes the response when the stream is closed.\n     *\n     * @param videoId The video job ID\n     * @return InputStream of the MP4 binary data\n     */\n    public InputStream downloadVideoStream(String videoId) throws IOException {\n        Request request =\n                new Request.Builder()\n                        .url(baseUrl + \"/v1/videos/\" + videoId + \"/content\")\n                        .header(\"Authorization\", \"Bearer \" + apiKey)\n                        .get()\n                        .build();\n\n        // Do not use try-with-resources here: the caller owns the stream lifecycle\n        Response response = httpClient.newCall(request).execute();\n        if (!response.isSuccessful()) {\n            String errorBody = readResponseBody(response);\n            response.close();\n            throw new IOException(\n                    \"OpenAI Video download failed with status %d: %s\"\n                            .formatted(response.code(), errorBody));\n        }\n\n        ResponseBody body = response.body();\n        if (body == null) {\n            response.close();\n            throw new IOException(\"OpenAI Video download returned empty body\");\n        }\n        return body.byteStream();\n    }\n\n    /**\n     * Download the completed video as a byte array.\n     *\n     * @param videoId The video job ID\n     * @return byte array of the MP4 binary data\n     */","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/ai/src/main/java/org/conductoross/conductor/ai/providers/openai/api/OpenAIVideoApi.java#L152-L188","documentation":"Thrown by OpenAIVideoApi.downloadVideoStream when GET /v1/videos/{id}/content returns non-2xx. This is the streaming variant (returns InputStream); the response is manually closed on failure and the error body is captured. IOException message includes status code and body.","triggerScenarios":"Downloading before the job status is 'completed' (400/409), the video asset has expired (404/410), invalid key (401), or rate limiting (429).","commonSituations":"Calling downloadVideoStream before getVideoStatus reports a terminal 'completed' state, waiting too long so the MP4 TTL expired, or a transient gateway error during the multi-minute download.","solutions":["Only call download after getVideoStatus returns status='completed'.","On 404/410, regenerate the video; the stored asset is gone.","For 429, retry the download with backoff.","If using the stream, ensure the caller closes the InputStream to release the connection."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Only attempt download once status is terminal-successful\nVideoStatusResponse status = videoApi.getVideoStatus(videoId);\nif (!\"completed\".equalsIgnoreCase(status.status())) {\n    throw new IllegalStateException(\"Video not completed: \" + status.status());\n}","typeGuard":null,"tryCatchPattern":"try (InputStream in = videoApi.downloadVideoStream(videoId)) {\n    // consume stream, must close to release connection\n} catch (IOException e) {\n    if (e.getMessage().contains(\"status 404\") || e.getMessage().contains(\"status 410\")) {\n        // asset gone - regenerate\n    } else {\n        throw e;\n    }\n}","preventionTips":["Only download after getVideoStatus reports 'completed'.","Always close the returned InputStream to release the connection.","Handle 404/410 as terminal (regenerate the video).","Use streaming for large MP4s instead of loading into memory."],"tags":["openai","video","sora","http","download","streaming"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}