# Buggy code
def take_action(self, parsed_args):
    self.log.debug("take_action(%s)", parsed_args)
    super(LocateObject, self).take_action(parsed_args)

    account = self.app.client_manager.get_account()
    container = parsed_args.container
    obj = parsed_args.object
    if parsed_args.auto:
        container = self.flatns_manager(obj)

    data = self.app.client_manager.storage.object_analyze(
        account, container, obj, version=parsed_args.object_version
    )

    def sort_chunk_pos(c1, c2):
        c1_tokens = c1[0].split(".")
        c2_tokens = c2[0].split(".")
        c1_pos = int(c1_tokens[0])
        c2_pos = int(c2_tokens[0])
        if len(c1_tokens) == 1 or c1_pos != c2_pos:
            return c1_pos - c2_pos
        return cmp(c1[0], c2[0])

    def get_chunks_info(chunks):
        pool_manager = get_pool_manager()
        chunk_hash = ""
        chunk_size = ""
        for c in chunks:
            resp = pool_manager.request("HEAD", c["url"])
            if resp.status != 200:
                chunk_size = "%d %s" % (resp.status, resp.reason)
                chunk_hash = "%d %s" % (resp.status, resp.reason)
            else:
                chunk_size = resp.headers.get(
                    "X-oio-chunk-meta-chunk-size", "Missing chunk size header"
                )
                chunk_hash = resp.headers.get(
                    "X-oio-chunk-meta-chunk-hash", "Missing chunk hash header"
                )
            yield (c["pos"], c["url"], c["size"], c["hash"], chunk_size, chunk_hash)

    columns = ()
    chunks = []
    if parsed_args.chunk_info:
        columns = (
            "Pos",
            "Id",
            "Metachunk size",
            "Metachunk hash",
            "Chunk size",
            "Chunk hash",
        )
        chunks = get_chunks_info(data[1])
    else:
        columns = ("Pos", "Id", "Metachunk size", "Metachunk hash")
        chunks = ((c["pos"], c["url"], c["size"], c["hash"]) for c in data[1])

    return columns, sorted(chunks, cmp=sort_chunk_pos)


# Traceback (KeyError)
Checking object "account=AUTH_demo, container=testing, obj=magic"
Checking container "account=AUTH_demo, container=testing, obj=magic"
Checking account "account=AUTH_demo, container=testing, obj=magic"
Exception object "account=AUTH_demo, container=testing, obj=magic": ('reqid=None', 'Connection aborted.', HTTPException('got more than 100 headers',))
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/eventlet/greenpool.py", line 82, in _spawn_n_impl
func(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/oio/crawler/integrity.py", line 244, in check_obj
self.check_obj_policy(target.copy(), meta, results)
File "/usr/lib/python2.7/site-packages/oio/crawler/integrity.py", line 185, in check_obj_policy
stg_met = STORAGE_METHODS.load(obj_meta['chunk_method'])
KeyError: 'chunk_method'

Report
Accounts checked  : 1

Containers checked: 1

Objects checked   : 0
Exceptions        : 1

Chunks checked    : 0

# Fixed code
def take_action(self, parsed_args):
    self.log.debug("take_action(%s)", parsed_args)
    super(LocateObject, self).take_action(parsed_args)

    account = self.app.client_manager.get_account()
    container = parsed_args.container
    obj = parsed_args.object
    if parsed_args.auto:
        container = self.flatns_manager(obj)

    data = self.app.client_manager.storage.object_locate(
        account, container, obj, version=parsed_args.object_version, properties=False
    )

    def sort_chunk_pos(c1, c2):
        c1_tokens = c1[0].split(".")
        c2_tokens = c2[0].split(".")
        c1_pos = int(c1_tokens[0])
        c2_pos = int(c2_tokens[0])
        if len(c1_tokens) == 1 or c1_pos != c2_pos:
            return c1_pos - c2_pos
        return cmp(c1[0], c2[0])

    def get_chunks_info(chunks):
        pool_manager = get_pool_manager()
        chunk_hash = ""
        chunk_size = ""
        for c in chunks:
            resp = pool_manager.request("HEAD", c["url"])
            if resp.status != 200:
                chunk_size = "%d %s" % (resp.status, resp.reason)
                chunk_hash = "%d %s" % (resp.status, resp.reason)
            else:
                chunk_size = resp.headers.get(
                    "X-oio-chunk-meta-chunk-size", "Missing chunk size header"
                )
                chunk_hash = resp.headers.get(
                    "X-oio-chunk-meta-chunk-hash", "Missing chunk hash header"
                )
            yield (c["pos"], c["url"], c["size"], c["hash"], chunk_size, chunk_hash)

    columns = ()
    chunks = []
    if parsed_args.chunk_info:
        columns = (
            "Pos",
            "Id",
            "Metachunk size",
            "Metachunk hash",
            "Chunk size",
            "Chunk hash",
        )
        chunks = get_chunks_info(data[1])
    else:
        columns = ("Pos", "Id", "Metachunk size", "Metachunk hash")
        chunks = ((c["pos"], c["url"], c["size"], c["hash"]) for c in data[1])

    return columns, sorted(chunks, cmp=sort_chunk_pos)