A deployment might report a successful HTTP 200 status for a hero image, yet the file could be truncated, corrupted, or a stale version from a previous build. Relying on headers alone is insufficient because the server may return a complete status code even if the underlying byte stream is incomplete or incorrect.
Quick solution:
curl -s https://example.com/hero.jpg | sha256sum
# Validate the raster structure using ImageMagick
identify -verbose hero.jpg
To ensure your production assets match the approved source, you must move beyond metadata checks. While it is essential to Validate Raster Images in CI Beyond Metadata before deployment, you must also verify the final, publicly accessible bytes. A stale image might be perfectly valid in format but fail to match the expected fingerprint, while a truncated file will often fail during the decoding process.
Comparing Hashes for Integrity
To confirm the exact file is served, calculate the hash of the downloaded body and compare it against your known-good fingerprint. You can use the Node.js crypto.createHash API to automate this in a test suite. If the hash does not match, the asset is either stale or has been modified by an unintended process.
Decoding for Structural Validity
Even if the hash matches, you should perform a full decode to ensure the file is not truncated. The ImageMagick identify tool is effective here; it reads the image structure and will report an error if the file is incomplete or corrupt.
Interpreting Release Report Outcomes
When running these checks in a CI pipeline, your report should distinguish between three primary failure modes:
-
Stale Asset: The hash comparison fails, but
identifyreports a valid image. This indicates the file is structurally sound but is not the version you approved.-
Report Output:
Expected: a1b2c3d4... Got: e5f6g7h8...
-
Report Output:
-
Truncated Bytes: The hash comparison fails, and
identifythrows a decoding error. This confirms the file is incomplete.-
Report Output:
identify: Premature end of JPEG file
-
Report Output:
-
Dimension Mismatch: The hash matches, but the image dimensions differ from your design specification. This often occurs when an optimization pipeline inadvertently alters the output.
-
Report Output:
Expected: 1920x1080 Got: 1280x720
-
Report Output:
Release Verification Checklist
- Download the hero image using a strict timeout to avoid hanging on partial responses.
- Compare the SHA-256 hash of the downloaded bytes against the approved release fingerprint.
- Run
identify -verboseon the downloaded file to ensure the decoder processes the entire raster without error. - Verify that the image dimensions match the expected design specifications, as optimization pipelines can sometimes alter file structure.
- Confirm that the HTTP 200 response contains the expected Content-Length header if your server provides one.
Top comments (0)