jackwener/OpenCLI · warning

Midjourney CDN reported ${media.mime || 'unknown'} for ${res

Error message

Midjourney CDN reported ${media.mime || 'unknown'} for ${resolved.url}; detected ${actualMime} from file bytes

What it means

The Content-Type the Midjourney CDN reported for an original image disagrees with the MIME type sniffed from the actual downloaded bytes. The code already validated the bytes are a real image and only logs a warning, then uses the sniffed type (e.g., to pick the file extension).

Source

Thrown at clis/midjourney/utils.js:667

  let media = null;
  let resolved = null;
  let lastError = null;
  for (const candidate of candidates) {
    try {
      media = await fetchMediaThroughPage(page, candidate.url, 'image/');
      resolved = candidate;
      break;
    } catch (error) {
      lastError = error;
    }
  }
  if (!media || !resolved) throw lastError || new CommandExecutionError(`No Midjourney original image was available for ${jobId}`);
  const actualMime = sniffMediaMime(media.buffer);
  if (!actualMime?.startsWith('image/')) {
    throw new CommandExecutionError(`Midjourney original image returned invalid media bytes from ${resolved.url}`);
  }
  if (media.mime !== actualMime) {
    log.warn(`Midjourney CDN reported ${media.mime || 'unknown'} for ${resolved.url}; detected ${actualMime} from file bytes`);
  }
  const extension = actualMime === 'image/png'
    ? '.png'
    : actualMime === 'image/webp'
      ? '.webp'
      : actualMime === 'image/gif'
        ? '.gif'
        : '.jpg';
  const filePath = path.join(outputDir, `${jobId}_${index}${extension}`);

  const tempPath = `${filePath}.part-${process.pid}-${Date.now()}`;
  try {
    await fs.writeFile(tempPath, media.buffer);
    await fs.rename(tempPath, filePath);
  } catch (error) {
    await fs.unlink(tempPath).catch(() => {});
    throw new CommandExecutionError(`Could not write Midjourney image ${filePath}: ${errorMessage(error)}`);
  }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. No action strictly required — the sniffed MIME wins and the correct extension is applied
  2. If extension matters, verify the saved file opens correctly with the sniffed type
  3. Check whether a proxy/antivirus is rewriting response headers in your environment
  4. Retry the download if the file is actually corrupted
Defensive patterns

Strategy: validation

Validate before calling

const mime = require('mime-sniffer'); // or file-type
const type = await sniff(buffer);
if (!type?.startsWith('image/')) throw new Error('Invalid image bytes');

Type guard

function isImageMime(m) { return typeof m === 'string' && m.startsWith('image/'); }

Try / catch

try {
  await downloadOriginalImage(page, jobId, index);
} catch (err) {
  if (err instanceof CommandExecutionError && /invalid media bytes/.test(err.message)) {
    // retry download or skip this asset
  }
}

Prevention

When it happens

Trigger: Downloading a Midjourney original image where the HTTP response header mime (media.mime) differs from sniffMediaMime(buffer) — but the bytes are still a valid image/* type.

Common situations: CDN behind a proxy/CDN layer rewriting Content-Type headers (e.g., serving application/octet-stream), signed URLs served with generic MIME, misconfigured CDN cache, images transcoded mid-flight.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/959cbb7e2e93cb91. Report an issue: GitHub.