conductor-oss/conductor · error · IOException

OpenAI Video download returned empty body

Error message

OpenAI Video download returned empty body

What it means

Thrown by OpenAIVideoApi.downloadVideoStream when the content endpoint returns 2xx but response.body() is null. The response is closed before throwing. A defensive guard for abnormal proxy/gateway behavior on a binary endpoint.

Source

Thrown at ai/src/main/java/org/conductoross/conductor/ai/providers/openai/api/OpenAIVideoApi.java:178

                        .url(baseUrl + "/v1/videos/" + videoId + "/content")
                        .header("Authorization", "Bearer " + apiKey)
                        .get()
                        .build();

        // Do not use try-with-resources here: the caller owns the stream lifecycle
        Response response = httpClient.newCall(request).execute();
        if (!response.isSuccessful()) {
            String errorBody = readResponseBody(response);
            response.close();
            throw new IOException(
                    "OpenAI Video download failed with status %d: %s"
                            .formatted(response.code(), errorBody));
        }

        ResponseBody body = response.body();
        if (body == null) {
            response.close();
            throw new IOException("OpenAI Video download returned empty body");
        }
        return body.byteStream();
    }

    /**
     * Download the completed video as a byte array.
     *
     * @param videoId The video job ID
     * @return byte array of the MP4 binary data
     */
    public byte[] downloadVideo(String videoId) throws IOException {
        Request request =
                new Request.Builder()
                        .url(baseUrl + "/v1/videos/" + videoId + "/content")
                        .header("Authorization", "Bearer " + apiKey)
                        .get()
                        .build();

View on GitHub (pinned to cf7c3e4a8a)

Solutions

  1. Call OpenAI directly bypassing proxies to confirm the body is present.
  2. Audit OkHttp interceptors on the shared client for premature body reads.
  3. Ensure the gateway passes through the binary content type and body unchanged.
Defensive patterns

Strategy: try-catch

Try / catch

try (InputStream in = videoApi.downloadVideoStream(videoId)) {
    // consume
} catch (IOException e) {
    if (e.getMessage().contains("empty body")) {
        // proxy stripped the body; try the direct endpoint
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: A proxy or gateway strips the MP4 body while forwarding a 200, or an OkHttp interceptor consumes the body before downloadVideoStream reads it.

Common situations: Corporate proxy rewriting binary responses, a misconfigured CDN, or a shared httpClient with logging interceptors that fully drain large bodies.

Related errors


AI-assisted analysis of conductor-oss/conductor@cf7c3e4a8a (2026-08-14). Data as JSON: /api/errors/c29911d2509d73cd. Report an issue: GitHub.