# Buggy code
def update_check_graph(self, deps_graph, output):
    """update the lockfile, checking for security that only nodes that are being built
    from sources can change their PREF, or nodes that depend on some other "modified"
    package, because their binary-id can change too
    """

    affected = self._closure_affected()
    for node in deps_graph.nodes:
        if node.recipe == RECIPE_VIRTUAL:
            continue
        try:
            lock_node = self._nodes[node.id]
        except KeyError:
            if node.recipe == RECIPE_CONSUMER:
                continue  # If the consumer node is not found, could be a test_package
            raise
        if lock_node.pref:
            pref = (
                lock_node.pref
                if self.revisions_enabled
                else lock_node.pref.copy_clear_revs()
            )
            node_pref = (
                node.pref if self.revisions_enabled else node.pref.copy_clear_revs()
            )
            # If the update is compatible (resolved complete PREV) or if the node has
            # been build, then update the graph
            if (
                pref.id == PACKAGE_ID_UNKNOWN
                or pref.is_compatible_with(node_pref)
                or node.binary == BINARY_BUILD
                or node.id in affected
                or node.recipe == RECIPE_CONSUMER
            ):
                self._upsert_node(node)
            else:
                raise ConanException(
                    "Mismatch between lock and graph:\nLock:  %s\nGraph: %s"
                    % (repr(pref), repr(node.pref))
                )


# Traceback (AssertionError)
D:\JenkinsCI\workspace\Concepts\CI-PkgA\build>conan graph build-order ./integration_deps --json=build_order.json --build=missing
Using lockfile: 'D:\JenkinsCI\workspace\Concepts\CI-PkgA\build\integration_deps\conan.lock'
Traceback (most recent call last):
File "c:\python37\lib\site-packages\conans\client\command.py", line 1969, in run
method(args[0][1:])
File "c:\python37\lib\site-packages\conans\client\command.py", line 1801, in graph
build_order = self._conan.build_order(args.lockfile, args.build)
File "c:\python37\lib\site-packages\conans\client\conan_api.py", line 81, in wrapper
return f(api, *args, **kwargs)
File "c:\python37\lib\site-packages\conans\client\conan_api.py", line 1216, in build_order
reference = graph_info.graph_lock.root_node_ref()
File "c:\python37\lib\site-packages\conans\model\graph_lock.py", line 185, in root_node_ref
assert len(roots) == 1
AssertionError

ERROR:

# Fixed code
def update_check_graph(self, deps_graph, output):
    """update the lockfile, checking for security that only nodes that are being built
    from sources can change their PREF, or nodes that depend on some other "modified"
    package, because their binary-id can change too
    """

    affected = self._closure_affected()
    for node in deps_graph.nodes:
        if node.recipe == RECIPE_VIRTUAL:
            continue
        try:
            lock_node = self._nodes[node.id]
        except KeyError:
            if node.recipe == RECIPE_CONSUMER:
                continue  # If the consumer node is not found, could be a test_package
            raise
        if lock_node.pref:
            pref = (
                lock_node.pref
                if self.revisions_enabled
                else lock_node.pref.copy_clear_revs()
            )
            node_pref = (
                node.pref if self.revisions_enabled else node.pref.copy_clear_revs()
            )
            # If the update is compatible (resolved complete PREV) or if the node has
            # been build, then update the graph
            if (
                pref.id == PACKAGE_ID_UNKNOWN
                or pref.is_compatible_with(node_pref)
                or node.binary == BINARY_BUILD
                or node.id in affected
                or node.recipe == RECIPE_CONSUMER
            ):
                lock_node.pref = node.pref
            else:
                raise ConanException(
                    "Mismatch between lock and graph:\nLock:  %s\nGraph: %s"
                    % (repr(pref), repr(node.pref))
                )