# Buggy code
def _handle_node_cache(self, node, keep_build, processed_package_references, remotes):
    pref = node.pref
    assert pref.id, "Package-ID without value"
    assert pref.id != PACKAGE_ID_UNKNOWN, "Package-ID error: %s" % str(pref)
    conanfile = node.conanfile
    output = conanfile.output

    layout = self._cache.package_layout(pref.ref, conanfile.short_paths)

    with layout.package_lock(pref):
        if pref not in processed_package_references:
            processed_package_references.add(pref)
            if node.binary == BINARY_BUILD:
                assert node.prev is None, (
                    "PREV for %s to be built should be None" % str(pref)
                )
                layout.package_remove(pref)
                with layout.set_dirty_context_manager(pref):
                    pref = self._build_package(node, output, keep_build, remotes)
                assert node.prev, "Node PREV shouldn't be empty"
                assert node.pref.revision, "Node PREF revision shouldn't be empty"
                assert pref.revision is not None, (
                    "PREV for %s to be built is None" % str(pref)
                )
            elif node.binary in (BINARY_UPDATE, BINARY_DOWNLOAD):
                # this can happen after a re-evaluation of packageID with Package_ID_unknown
                self._download_pkg(layout, node)
            elif node.binary == BINARY_CACHE:
                assert node.prev, "PREV for %s is None" % str(pref)
                output.success("Already installed!")
                log_package_got_from_local_cache(pref)
                self._recorder.package_fetched_from_cache(pref)

        package_folder = layout.package(pref)
        if not os.path.isdir(package_folder):
            raise ConanException(
                "Package '%s' corrupted. Package folder must exist: %s\n"
                "Try removing the package with 'conan remove'"
                % (str(pref), package_folder)
            )
        # Call the info method
        self._call_package_info(conanfile, package_folder, ref=pref.ref)
        self._recorder.package_cpp_info(pref, conanfile.cpp_info)


# Traceback (AssertionError)
conan info poco/1.9.4@ --paths
Traceback (most recent call last):
File "C:\Users\Daniel\AppData\Roaming\Python\Python37\site-packages\conans\client\command.py", line 2115, in run
method(args[0][1:])
File "C:\Users\Daniel\AppData\Roaming\Python\Python37\site-packages\conans\client\command.py", line 747, in info
lockfile=args.lockfile)
File "C:\Users\Daniel\AppData\Roaming\Python\Python37\site-packages\conans\client\conan_api.py", line 94, in wrapper
return f(api, *args, **kwargs)
File "C:\Users\Daniel\AppData\Roaming\Python\Python37\site-packages\conans\client\conan_api.py", line 743, in info
update, False, remotes, recorder)
File "C:\Users\Daniel\AppData\Roaming\Python\Python37\site-packages\conans\client\graph\graph_manager.py", line 116, in load_graph
apply_build_requires=apply_build_requires)
File "C:\Users\Daniel\AppData\Roaming\Python\Python37\site-packages\conans\client\graph\graph_manager.py", line 244, in _resolve_graph
graph_lock=graph_lock)
File "C:\Users\Daniel\AppData\Roaming\Python\Python37\site-packages\conans\client\graph\graph_manager.py", line 363, in _load_graph
apply_build_requires=apply_build_requires)
File "C:\Users\Daniel\AppData\Roaming\Python\Python37\site-packages\conans\client\graph\graph_manager.py", line 284, in _recurse_build_requires
self._binary_analyzer.evaluate_graph(graph, build_mode, update, remotes, nodes_subset, root)
File "C:\Users\Daniel\AppData\Roaming\Python\Python37\site-packages\conans\client\graph\graph_binaries.py", line 384, in evaluate_graph
self._evaluate_node(node, build_mode, update, remotes)
File "C:\Users\Daniel\AppData\Roaming\Python\Python37\site-packages\conans\client\graph\graph_binaries.py", line 176, in _evaluate_node
self._process_node(node, pref, build_mode, update, remotes)
File "C:\Users\Daniel\AppData\Roaming\Python\Python37\site-packages\conans\client\graph\graph_binaries.py", line 242, in _process_node
self._evaluate_cache_pkg(node, package_layout, pref, metadata, remote, remotes, update)
File "C:\Users\Daniel\AppData\Roaming\Python\Python37\site-packages\conans\client\graph\graph_binaries.py", line 95, in _evaluate_cache_pkg
assert node.prev, "PREV for %s is None: %s" % (str(pref), metadata.dumps())
AssertionError: PREV for poco/1.9.4:e800054a13ea39bf75eb479d61dc6ce27dd9c321 is None: {"recipe": {"revision": "0", "remote": "conan-center", "properties": {}, "checksums": {"conanmanifest.txt": {"md5": "1c74dc82b5b19f764f9e39ef3530fac9", "sha1": "c0dce2f8e0394be5932455f35d3103877d184bdc"}, "conanfile.py": {"md5": "8315dcc96b131b21d4d64d7f56e73d99", "sha1": "b768bea077de938ea0b95baf916bf6b96101e694"}, "conan_export.tgz": {"md5": "5819fbc0b48456426c49daba6b4d85be", "sha1": "33bca842766631e007b7f5fa21b9770217328b7f"}}}, "packages": {"e800054a13ea39bf75eb479d61dc6ce27dd9c321": {"revision": null, "recipe_revision": null, "remote": null, "properties": {}, "checksums": {}}}}

ERROR: PREV for poco/1.9.4:e800054a13ea39bf75eb479d61dc6ce27dd9c321 is None: {"recipe": {"revision": "0", "remote": "conan-center", "properties": {}, "checksums": {"conanmanifest.txt": {"md5": "1c74dc82b5b19f764f9e39ef3530fac9", "sha1": "c0dce2f8e0394be5932455f35d3103877d184bdc"}, "conanfile.py": {"md5": "8315dcc96b131b21d4d64d7f56e73d99", "sha1": "b768bea077de938ea0b95baf916bf6b96101e694"}, "conan_export.tgz": {"md5": "5819fbc0b48456426c49daba6b4d85be", "sha1": "33bca842766631e007b7f5fa21b9770217328b7f"}}}, "packages": {"e800054a13ea39bf75eb479d61dc6ce27dd9c321": {"revision": null, "recipe_revision": null, "remote": null, "properties": {}, "checksums": {}}}}

# Fixed code
def _handle_node_cache(self, node, keep_build, processed_package_references, remotes):
    pref = node.pref
    assert pref.id, "Package-ID without value"
    assert pref.id != PACKAGE_ID_UNKNOWN, "Package-ID error: %s" % str(pref)
    conanfile = node.conanfile
    output = conanfile.output

    layout = self._cache.package_layout(pref.ref, conanfile.short_paths)

    with layout.package_lock(pref):
        if pref not in processed_package_references:
            processed_package_references.add(pref)
            if node.binary == BINARY_BUILD:
                assert node.prev is None, (
                    "PREV for %s to be built should be None" % str(pref)
                )
                layout.package_remove(pref)
                with layout.set_dirty_context_manager(pref):
                    pref = self._build_package(node, output, keep_build, remotes)
                assert node.prev, "Node PREV shouldn't be empty"
                assert node.pref.revision, "Node PREF revision shouldn't be empty"
                assert pref.revision is not None, (
                    "PREV for %s to be built is None" % str(pref)
                )
            elif node.binary in (BINARY_UPDATE, BINARY_DOWNLOAD):
                # this can happen after a re-evaluation of packageID with Package_ID_unknown
                self._download_pkg(layout, node)
            elif node.binary == BINARY_CACHE:
                assert node.prev, "PREV for %s is None" % str(pref)
                output.success("Already installed!")
                log_package_got_from_local_cache(pref)
                self._recorder.package_fetched_from_cache(pref)

        package_folder = layout.package(pref)
        assert os.path.isdir(package_folder), "Package '%s' folder must exist: %s\n" % (
            str(pref),
            package_folder,
        )
        # Call the info method
        self._call_package_info(conanfile, package_folder, ref=pref.ref)
        self._recorder.package_cpp_info(pref, conanfile.cpp_info)