Handle errors from getCount or getS3Header

We have seen an error there in the field, but it went unlogged. Since we didn't fail gracefully, the subsequent code crashed dereferencing `undefined`.

/cc @hampelm