Repository: conan-io/conan

Issue:
[bug] `conan graph build-order --order=configuration` raising with stacktrace
### Environment details

* Operating System+version: Latest macos
* Conan version: 2.1.0-dev
* Python version: 3.11


### Steps to reproduce

Running `conan graph build-order --requires=ffmpeg/6.1 --order=configuration` currently raises with an stack trace. I'm investigating with @jcar87 

### Logs

```
======== Computing the build order ========
ERROR: Traceback (most recent call last):
  File "/Users/ruben/coding/build-tools/venv/lib/python3.11/site-packages/conan/cli/cli.py", line 281, in main
    cli.run(args)
  File "/Users/ruben/coding/build-tools/venv/lib/python3.11/site-packages/conan/cli/cli.py", line 191, in run
    command.run(self._conan_api, args[0][1:])
  File "/Users/ruben/coding/build-tools/venv/lib/python3.11/site-packages/conan/cli/command.py", line 158, in run
    sub.run(conan_api, parser, *args)
  File "/Users/ruben/coding/build-tools/venv/lib/python3.11/site-packages/conan/cli/command.py", line 174, in run
    self._format(parent_parser, info, *args)
  File "/Users/ruben/coding/build-tools/venv/lib/python3.11/site-packages/conan/cli/command.py", line 98, in _format
    formatter(info)
  File "/Users/ruben/coding/build-tools/venv/lib/python3.11/site-packages/conan/cli/commands/graph.py", line 44, in cli_build_order
    for package_level in item['packages']:
                         ~~~~^^^^^^^^^^^^
KeyError: 'packages'

ERROR: 'packages'
```


Discussion:

Patch:
diff --git a/conan/cli/commands/graph.py b/conan/cli/commands/graph.py
index d8babfefa96..be24398838a 100644
--- a/conan/cli/commands/graph.py
+++ b/conan/cli/commands/graph.py
@@ -41,9 +41,13 @@ def cli_build_order(build_order):
     # TODO: Very simple cli output, probably needs to be improved
     for level in build_order:
         for item in level:
-            for package_level in item['packages']:
-                for package in package_level:
-                    cli_out_write(f"{item['ref']}:{package['package_id']} - {package['binary']}")
+            # If this is a configuration order, it has no packages entry, each item is a package
+            if 'packages' in item:
+                for package_level in item['packages']:
+                    for package in package_level:
+                        cli_out_write(f"{item['ref']}:{package['package_id']} - {package['binary']}")
+            else:
+                cli_out_write(f"{item['ref']}:{item['package_id']} - {item['binary']}")
 
 
 def json_build_order(build_order):


Test patch:
diff --git a/conans/test/integration/command_v2/test_info_build_order.py b/conans/test/integration/command_v2/test_info_build_order.py
index 3f484445761..bee61443026 100644
--- a/conans/test/integration/command_v2/test_info_build_order.py
+++ b/conans/test/integration/command_v2/test_info_build_order.py
@@ -111,6 +111,21 @@ def test_info_build_order_configuration():
     assert bo_json == result
 
 
+def test_info_build_order_configuration_text_formatter():
+    c = TestClient()
+    c.save({"dep/conanfile.py": GenConanfile(),
+            "pkg/conanfile.py": GenConanfile().with_requires("dep/0.1"),
+            "consumer/conanfile.txt": "[requires]\npkg/0.1"})
+    c.run("export dep --name=dep --version=0.1")
+    c.run("export pkg --name=pkg --version=0.1")
+    c.run("graph build-order consumer --build=missing --order=configuration --format=text")
+    assert textwrap.dedent("""\
+    ======== Computing the build order ========
+    dep/0.1#4d670581ccb765839f2239cc8dff8fbd:da39a3ee5e6b4b0d3255bfef95601890afd80709 - Build
+    pkg/0.1#1ac8dd17c0f9f420935abd3b6a8fa032:59205ba5b14b8f4ebc216a6c51a89553021e82c1 - Build
+    """) in c.out
+
+
 def test_info_build_order_build_require():
     c = TestClient()
     c.save({"dep/conanfile.py": GenConanfile(),