Skip to content

How should my app serve an output that claims to be an image but fails media inspection?

Treat a mismatch between claimed type and inspected content as a delivery-validation problem. Keep the bytes out of trusted inline preview routes until reviewed. AISwapLab completion and HTTP headers are useful evidence, but your application should not serve unexpected active content as if it were a verified image.

PROTECT API ACCESS AND RESULTSAISwapLab team · Editorial methodPublished 2 min read
Open API documentationExplore 67 Image SkillsPrivate keys · Explicit credit approval
Article workflow: Define expected types per task; Quarantine mismatches; Serve verified content deliberately.
Workflow diagram: Define expected types per task → Quarantine mismatches → Serve verified content deliberately. Read the article for evidence and limits.

Preview promotion is a trust decision

A file extension and Content-Type can disagree with actual bytes. Serving unknown content from the same origin as your application can create additional browser risk. Define a limited set of accepted output formats and inspect them before attaching a trusted preview.

What to do next

  1. 01

    Define expected types per task

    Derive the allowed media family from the submitted operation and reviewed contract, then validate headers and bytes using an appropriate parser. Text JSON, raster images and MP4 video need different inspection paths.

  2. 02

    Quarantine mismatches

    Do not repair a suspicious object merely by changing its extension. Store restricted diagnostics or quarantine evidence under your local policy, and keep it away from normal inline rendering and automatic publication.

  3. 03

    Serve verified content deliberately

    Set the correct content type, appropriate disposition and no-sniff behavior at your own final response boundary. Test a synthetic HTML body labeled as an image to ensure it cannot become active content on the application origin.

A concrete example

Illustrative example: a fixture returns image/png but contains HTML text. The application rejects promotion to the image gallery and records a delivery-validation issue, preserving the original task reference for investigation.

Before you call it ready

  • Expected types come from the operation.
  • Mismatch bytes never reach trusted inline routes.
  • Final response headers match verified content.

When to stop or choose another method

Stop fixing a type mismatch by renaming the file or trusting its extension without inspecting the representation you will serve.

Sources

One task. A recoverable workflow.

Check the contract, approve the quote and retain the job.

Open API documentation