# Buggy code
def contains(bank, key):
    """
    Checks if the specified bank contains the specified key.
    """
    _init_client()
    etcd_key = "{0}/{1}/{2}".format(path_prefix, bank, key)
    try:
        r = client.get(etcd_key)
        # return True for keys, not dirs
        return r.dir is False
    except etcd.EtcdKeyNotFound:
        return False
    except Exception as exc:
        raise SaltCacheError(
            "There was an error getting the key, {0}: {1}".format(etcd_key, exc)
        )


# Traceback (SaltCacheError)
salt-master[3903]: [ERROR   ] Error in function _mine:
salt-master[3903]: Traceback (most recent call last):
salt-master[3903]:   File "/usr/lib/python2.7/dist-packages/salt/master.py", line 1776, in run_func
salt-master[3903]:     ret = getattr(self, func)(load)
salt-master[3903]:   File "/usr/lib/python2.7/dist-packages/salt/master.py", line 1345, in _mine
salt-master[3903]:     return self.masterapi._mine(load, skip_verify=True)
salt-master[3903]:   File "/usr/lib/python2.7/dist-packages/salt/daemons/masterapi.py", line 607, in _mine
salt-master[3903]:     data = self.cache.fetch(cbank, ckey)
salt-master[3903]:   File "/usr/lib/python2.7/dist-packages/salt/cache/__init__.py", line 180, in fetch
salt-master[3903]:     return self.modules[fun](bank, key, **self._kwargs)
salt-master[3903]:   File "/usr/lib/python2.7/dist-packages/salt/cache/etcd_cache.py", line 150, in fetch
salt-master[3903]:     etcd_key, exc
salt-master[3903]: SaltCacheError: There was an error reading the key, /salt_cache/minions/ca.aws-cc1.dev.xxx.yyy.com/mine: Key not found : /salt_cache/minions/ca.aws-cc1.dev.xxx.yyy.com/mine
salt-master[3903]: [ERROR   ] Error in function _mine_get:
salt-master[3903]: Traceback (most recent call last):
salt-master[3903]:   File "/usr/lib/python2.7/dist-packages/salt/master.py", line 1776, in run_func
salt-master[3903]:     ret = getattr(self, func)(load)
salt-master[3903]:   File "/usr/lib/python2.7/dist-packages/salt/master.py", line 1331, in _mine_get
salt-master[3903]:     return self.masterapi._mine_get(load, skip_verify=True)
salt-master[3903]:   File "/usr/lib/python2.7/dist-packages/salt/daemons/masterapi.py", line 589, in _mine_get
salt-master[3903]:     fdata = self.cache.fetch('minions/{0}'.format(minion), 'mine')
salt-master[3903]:   File "/usr/lib/python2.7/dist-packages/salt/cache/__init__.py", line 180, in fetch
salt-master[3903]:     return self.modules[fun](bank, key, **self._kwargs)
salt-master[3903]:   File "/usr/lib/python2.7/dist-packages/salt/cache/etcd_cache.py", line 150, in fetch
salt-master[3903]:     etcd_key, exc
salt-master[3903]: SaltCacheError: There was an error reading the key, /salt_cache/minions/ca.aws-cc1.dev.xxx.yyy.com/mine: Key not found : /salt_cache/minions/ca.aws-cc1.dev.xxx.yyy.com/mine

# Fixed code
def contains(bank, key):
    """
    Checks if the specified bank contains the specified key.
    """
    _init_client()
    etcd_key = "{0}/{1}/{2}".format(path_prefix, bank, key)
    try:
        r = client.read(etcd_key)
        # return True for keys, not dirs
        return r.dir is False
    except etcd.EtcdKeyNotFound:
        return False
    except Exception as exc:
        raise SaltCacheError(
            "There was an error getting the key, {0}: {1}".format(etcd_key, exc)
        )