Correctly set the response code for the cached lookups and return the
error stream if the lookup failed