Repository: conan-io/conan

Issue:
[bug] conan profile show crashes when showing profilse with per-package conf variables
### Environment details

* Operating System+version: Windows 11 Pro 23H2
* Compiler+version: msvc 193
* Conan version: 2.1.0
* Python version: 3.12.2


### Steps to reproduce

I'm migrating my company to Conan V2, but need `conan profile show` to work to replace usages of `conan profile get` in our CI and justfiles where it is used to determine the name of the build directories and CMake presets. 

1. Create a profile which contains per-package conf settings like the following snippet.

```
[conf]
libiconv/*:tools.env.virtualenv:powershell=False
libgettext/*:tools.env.virtualenv:powershell=False
libffi/*:tools.env.virtualenv:powershell=False
```

Yes, these packages don't build correctly using Powershell and this configuration fixes building them when running conan install. Refer to conan-io/conan-center-index#21823.

2. Run the `conan profile show` command on this profile.

```
conan profile show --format json --profile:host "windows/msvc/2022/debug"
```

### Logs

```
ERROR: Traceback (most recent call last):
  File "C:\Users\Quickemu\AppData\Local\Programs\Python\Python312\Lib\site-packages\conan\cli\cli.py", line 281, in main
    cli.run(args)
  File "C:\Users\Quickemu\AppData\Local\Programs\Python\Python312\Lib\site-packages\conan\cli\cli.py", line 191, in run
    command.run(self._conan_api, args[0][1:])
  File "C:\Users\Quickemu\AppData\Local\Programs\Python\Python312\Lib\site-packages\conan\cli\command.py", line 158, in run
    sub.run(conan_api, parser, *args)
  File "C:\Users\Quickemu\AppData\Local\Programs\Python\Python312\Lib\site-packages\conan\cli\command.py", line 174, in run
    self._format(parent_parser, info, *args)
  File "C:\Users\Quickemu\AppData\Local\Programs\Python\Python312\Lib\site-packages\conan\cli\command.py", line 98, in _format
    formatter(info)
  File "C:\Users\Quickemu\AppData\Local\Programs\Python\Python312\Lib\site-packages\conan\cli\commands\profile.py", line 28, in json_profiles
    result = {"host": host.serialize(),
                      ^^^^^^^^^^^^^^^^
  File "C:\Users\Quickemu\AppData\Local\Programs\Python\Python312\Lib\site-packages\conans\model\profile.py", line 44, in serialize
    "conf": self.conf.serialize(),
            ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Quickemu\AppData\Local\Programs\Python\Python312\Lib\site-packages\conans\model\conf.py", line 648, in serialize
    for k, v in conf.serialize():
        ^^^^
ValueError: too many values to unpack (expected 2)

ERROR: too many values to unpack (expected 2)
```


Discussion:
Hi @jwillikers, thanks a lot for the report. This seems to have gone unnoticed for quite a bit going by the git history, which is suprising! I've proposed https://github.com/conan-io/conan/pull/15747 to fix the issue for the next Conan 2.2 release :)
Thanks!



Patch:
diff --git a/conans/model/conf.py b/conans/model/conf.py
index 65d7a6993b7..9743c6c7301 100644
--- a/conans/model/conf.py
+++ b/conans/model/conf.py
@@ -645,7 +645,7 @@ def serialize(self):
             if pattern is None:
                 result.update(conf.serialize())
             else:
-                for k, v in conf.serialize():
+                for k, v in conf.serialize().items():
                     result[f"{pattern}:{k}"] = v
         return result
 


Test patch:
diff --git a/conans/test/integration/command/test_profile.py b/conans/test/integration/command/test_profile.py
index 6446bc8aa30..d066f45f7bb 100644
--- a/conans/test/integration/command/test_profile.py
+++ b/conans/test/integration/command/test_profile.py
@@ -133,9 +133,13 @@ def test_shorthand_syntax():
 
 def test_profile_show_json():
     c = TestClient()
-    c.save({"myprofilewin": "[settings]\nos=Windows\n[tool_requires]\nmytool/*:mytool/1.0",
+    c.save({"myprofilewin": "[settings]\nos=Windows\n"
+                            "[tool_requires]\nmytool/*:mytool/1.0\n"
+                            "[conf]\nuser.conf:value=42\nlibiconv/*:tools.env.virtualenv:powershell=False\n"
+                            "[options]\n*:myoption=True",
             "myprofilelinux": "[settings]\nos=Linux"})
     c.run("profile show -pr:b=myprofilewin -pr:h=myprofilelinux --format=json")
+
     profile = json.loads(c.stdout)
     assert profile["host"]["settings"] == {"os": "Linux"}