I think it would be acceptable to just wrap this with:

    try:
        if obj:
            obj['etag'] = res['meta']['headers'].get('etag', '') 
    except KeyError:
        pass