# Buggy code
def Analyze(self, hashes):
    """Looks up hashes in Viper using the Viper HTTP API.

    The API is documented here:
      https://viper-framework.readthedocs.org/en/latest/usage/web.html#api

    Args:
      hashes: A list of hashes (strings) to look up. The Viper plugin supports
              only one hash at a time.

    Returns:
      A list of hash analysis objects (instances of HashAnalysis).

    Raises:
      RuntimeError: If no host has been set for Viper.
      ValueError: If the hashes list contains a number of hashes other than
                      one.
    """
    if not self._host:
        raise RuntimeError("No host specified for Viper lookup.")

    if len(hashes) != 1:
        raise ValueError(
            "Unsupported number of hashes provided. Viper supports only one "
            "hash at a time."
        )
    sha256 = hashes[0]

    hash_analyses = []
    url = "{0:s}://{1:s}/{2:s}".format(self._protocol, self._host, self._VIPER_API_PATH)
    params = {"sha256": sha256}
    try:
        json_response = self.MakeRequestAndDecodeJSON(url, "POST", data=params)
    except errors.ConnectionError as exception:
        logging.error(
            ("Error communicating with Viper {0:s}. Viper plugin is aborting.").format(
                exception
            )
        )
        self.SignalAbort()
        return hash_analyses

    hash_analysis = interface.HashAnalysis(sha256, json_response)
    hash_analyses.append(hash_analysis)
    return hash_analyses


# Traceback (KeyError)
[ERROR] (nsrlsvr   ) PID:XXXXX <analysis_process> <dfvfs.path.os_path_spec.OSPathSpec object at 0xXXXXXXXXXXXX>
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/plaso/multi_processing/analysis_process.py", line 138, in _Main
self._analysis_mediator.ProduceAnalysisReport(self._analysis_plugin)
File "/usr/lib/python2.7/dist-packages/plaso/analysis/mediator.py", line 95, in ProduceAnalysisReport
analysis_report = plugin.CompileReport(self)
File "/usr/lib/python2.7/dist-packages/plaso/analysis/interface.py", line 280, in CompileReport
hash_analysis)
File "/usr/lib/python2.7/dist-packages/plaso/analysis/interface.py", line 187, in _HandleHashAnalysis
event_uuids = self._event_uuids_by_pathspec.pop(pathspec)
KeyError: <dfvfs.path.os_path_spec.OSPathSpec object at 0xXXXXXXXXXXXX>

# Fixed code
def Analyze(self, hashes):
    """Looks up hashes in Viper using the Viper HTTP API.

    The API is documented here:
      https://viper-framework.readthedocs.org/en/latest/usage/web.html#api

    Args:
      hashes: A list of hashes (strings) to look up. The Viper plugin supports
              only one hash at a time.

    Returns:
      A list of hash analysis objects (instances of HashAnalysis).

    Raises:
      RuntimeError: If no host has been set for Viper.
      ValueError: If the hashes list contains a number of hashes other than
                      one.
    """
    if not self._host:
        raise RuntimeError("No host specified for Viper lookup.")

    if len(hashes) != 1:
        raise ValueError(
            "Unsupported number of hashes provided. Viper supports only one "
            "hash at a time."
        )
    sha256 = hashes[0]

    hash_analyses = []
    url = "{0:s}://{1:s}:{2:d}/{3:s}".format(
        self._protocol, self._host, self._port, self._VIPER_API_PATH
    )
    params = {"sha256": sha256}
    try:
        json_response = self.MakeRequestAndDecodeJSON(url, "POST", data=params)
    except errors.ConnectionError as exception:
        logging.error(
            ("Error communicating with Viper {0:s}. Viper plugin is aborting.").format(
                exception
            )
        )
        self.SignalAbort()
        return hash_analyses

    hash_analysis = interface.HashAnalysis(sha256, json_response)
    hash_analyses.append(hash_analysis)
    return hash_analyses