You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yet, if we request the output as Json format (in order to be able to parse to output with jq, as advised here), conan crashes with:
ERROR: Object of type RecipeReference is not JSON serializable
If we remove the tool_requires section of our profile, the json output works as expected.
Logs
ERROR: Traceback (most recent call last):
File "/Users/someguy/MigrationConan2/env/lib/python3.11/site-packages/conan/cli/cli.py", line 272, in main
cli.run(args)
File "/Users/someguy/MigrationConan2/env/lib/python3.11/site-packages/conan/cli/cli.py", line 172, in run
command.run(self._conan_api, args[0][1:])
File "/Users/someguy/MigrationConan2/env/lib/python3.11/site-packages/conan/cli/command.py", line 141, in run
sub.run(conan_api, parser, *args)
File "/Users/someguy/MigrationConan2/env/lib/python3.11/site-packages/conan/cli/command.py", line 157, in run
self._format(parent_parser, info, *args)
File "/Users/someguy/MigrationConan2/env/lib/python3.11/site-packages/conan/cli/command.py", line 94, in _format
formatter(info)
File "/Users/someguy/MigrationConan2/env/lib/python3.11/site-packages/conan/cli/commands/profile.py", line 30, in json_profiles
cli_out_write(json.dumps(result))
^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/init.py", line 231, in dumps
return _default_encoder.encode(obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py", line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py", line 258, in iterencode
return _iterencode(o, 0)
^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type RecipeReference is not JSON serializable
The text was updated successfully, but these errors were encountered:
Adnn
changed the title
[bug] conan profile show crashes when requesting json output if profile contains a reference.
[bug] conan profile show crashes when requesting json output if profile contains a reference.
Nov 27, 2023
Hi @Adnn thanks a lot for taking the time to report the issue.
I've proposed #15185 to fix it for the next 2.0.15 release, I still need to check with the team about the serialization of the reference itself or whether just outputting the string representation would be enough :)
Environment details
Steps to reproduce
Issuing
conan profile show -pr:h ourprofile
, we get:Yet, if we request the output as Json format (in order to be able to parse to output with
jq
, as advised here), conan crashes with:If we remove the
tool_requires
section of our profile, the json output works as expected.Logs
ERROR: Traceback (most recent call last):
File "/Users/someguy/MigrationConan2/env/lib/python3.11/site-packages/conan/cli/cli.py", line 272, in main
cli.run(args)
File "/Users/someguy/MigrationConan2/env/lib/python3.11/site-packages/conan/cli/cli.py", line 172, in run
command.run(self._conan_api, args[0][1:])
File "/Users/someguy/MigrationConan2/env/lib/python3.11/site-packages/conan/cli/command.py", line 141, in run
sub.run(conan_api, parser, *args)
File "/Users/someguy/MigrationConan2/env/lib/python3.11/site-packages/conan/cli/command.py", line 157, in run
self._format(parent_parser, info, *args)
File "/Users/someguy/MigrationConan2/env/lib/python3.11/site-packages/conan/cli/command.py", line 94, in _format
formatter(info)
File "/Users/someguy/MigrationConan2/env/lib/python3.11/site-packages/conan/cli/commands/profile.py", line 30, in json_profiles
cli_out_write(json.dumps(result))
^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/init.py", line 231, in dumps
return _default_encoder.encode(obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py", line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py", line 258, in iterencode
return _iterencode(o, 0)
^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type RecipeReference is not JSON serializable
The text was updated successfully, but these errors were encountered: