Monday, 10 October 2016

"Invalid/missing hash was encountered" for documents

Reviewing our logs recently we discovered that we were getting an unusually large number of messages to the tune of
ERROR MediaRequestProtection: An invalid/missing hash value was encountered.

As we all know, Sitecore 7.5 added the concept of a hash which is required when resizing media items, so naturally we assumed that some images were being included incorrectly on a page somewhere, or the secret was incorrectly configured.  However, on closer inspection we realised that it wasn't actually images at all, but documents (which certainly aren't being resized, and surely don't need a hash).

Documents (mostly PDFs) were being uploaded to the media library, and then in a rich text field somewhere on the site, an author was linking to the document using insert link -> media item.

Upon reaching out to Sitecore, they were quick to reply that this was actually a bug in the current version of Sitecore (8.1 update 2 - 160302).  So if you're having a similar issue and want to clean out your logs a bit, you can contact support for the patch, and/or use the reference number 438674.

2 comments:

  1. I've the same issue on one of my site and it's on only .jpg files. I have key entered in Sitecore.Media.RequestProtection.config and key is same on all app servers still i received these errors. Can you suggest anything else in this?

    ReplyDelete
  2. That’s a really insightful find. Sitecore’s handling of hashes for non-image media has tripped up a lot of teams, and it’s great that you identified it was linked to documents rather than images. These subtle implementation details often hide deep in enterprise systems and can have surprisingly large operational impacts if not caught early.

    Your approach to debugging and isolating the issue is a great example of proactive system stewardship — it reminds me of how effective test management tools can help maintain visibility across complex software ecosystems. Platforms like Tuskr test management software make it easier to trace these issues back to their origin and ensure similar regressions are prevented in future releases.

    ReplyDelete