Make V2 code more defensive against malformed content

Added more checks in the V2 code against possible malformed or changed content.  This code will only be hit when pulling from the V2 registry, which is still only for official images.

Ping @crosbymichael
also can we make this a `const ()` block, that will be my only nit i promise :)