Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments in authors array interpreted if a random tool section exists #6133

Closed
3 tasks done
languitar opened this issue Aug 8, 2022 · 3 comments
Closed
3 tasks done
Labels
kind/bug Something isn't working as expected

Comments

@languitar
Copy link

languitar commented Aug 8, 2022

Issue

The TOML languages allows comments inside arrays. When having such comments inside the authors array in pyproject.toml, the existence of any tool.* section not part of what poetry uses for its own purposes makes poetry in version 1.1.14 parse comments as actual authors.

With the provided pyproject.toml, a poetry install or any other command fails with:

  RuntimeError

  The Poetry configuration is invalid:
    - [authors.1] None is not of type 'string'
    - [authors.3] None is not of type 'string'
  

  at /usr/lib/python3.10/site-packages/poetry/core/factory.py:43 in create_poetry
       39│             message = ""
       40│             for error in check_result["errors"]:
       41│                 message += "  - {}\n".format(error)
       42│ 
    →  43│             raise RuntimeError("The Poetry configuration is invalid:\n" + message)
       44│ 
       45│         # Load package
       46│         name = local_config["name"]
       47│         version = local_config["version"]

/tmp/test via 🐍 v3.10.5 ☸ bau365-production (applications) 
❯ poetry install -vvv

  Stack trace:

  9  /usr/lib/python3.10/site-packages/clikit/console_application.py:131 in run
      129│             parsed_args = resolved_command.args
      130│ 
    → 131│             status_code = command.handle(parsed_args, io)
      132│         except KeyboardInterrupt:
      133│             status_code = 1

  8  /usr/lib/python3.10/site-packages/clikit/api/command/command.py:120 in handle
      118│     def handle(self, args, io):  # type: (Args, IO) -> int
      119│         try:
    → 120│             status_code = self._do_handle(args, io)
      121│         except KeyboardInterrupt:
      122│             if io.is_debug():

  7  /usr/lib/python3.10/site-packages/clikit/api/command/command.py:163 in _do_handle
      161│         if self._dispatcher and self._dispatcher.has_listeners(PRE_HANDLE):
      162│             event = PreHandleEvent(args, io, self)
    → 163│             self._dispatcher.dispatch(PRE_HANDLE, event)
      164│ 
      165│             if event.is_handled():

  6  /usr/lib/python3.10/site-packages/clikit/api/event/event_dispatcher.py:22 in dispatch
       20│ 
       21│         if listeners:
    →  22│             self._do_dispatch(listeners, event_name, event)
       23│ 
       24│         return event

  5  /usr/lib/python3.10/site-packages/clikit/api/event/event_dispatcher.py:89 in _do_dispatch
       87│                 break
       88│ 
    →  89│             listener(event, event_name, self)
       90│ 
       91│     def _sort_listeners(self, event_name):  # type: (str) -> None

  4  /usr/lib/python3.10/site-packages/poetry/console/config/application_config.py:116 in set_env
      114│ 
      115│         io = event.io
    → 116│         poetry = command.poetry
      117│ 
      118│         env_manager = EnvManager(poetry)

  3  /usr/lib/python3.10/site-packages/poetry/console/commands/command.py:10 in poetry
       8│     @property
       9│     def poetry(self):
    → 10│         return self.application.poetry
      11│ 
      12│     def reset_poetry(self):  # type: () -> None

  2  /usr/lib/python3.10/site-packages/poetry/console/application.py:69 in poetry
       67│             return self._poetry
       68│ 
    →  69│         self._poetry = Factory().create_poetry(Path.cwd())
       70│ 
       71│         return self._poetry

  1  /usr/lib/python3.10/site-packages/poetry/factory.py:33 in create_poetry
       31│             io = NullIO()
       32│ 
    →  33│         base_poetry = super(Factory, self).create_poetry(cwd)
       34│ 
       35│         locker = Locker(

  RuntimeError

  The Poetry configuration is invalid:
    - [authors.1] None is not of type 'string'
    - [authors.3] None is not of type 'string'
  

  at /usr/lib/python3.10/site-packages/poetry/core/factory.py:43 in create_poetry
       39│             message = ""
       40│             for error in check_result["errors"]:
       41│                 message += "  - {}\n".format(error)
       42│ 
    →  43│             raise RuntimeError("The Poetry configuration is invalid:\n" + message)
       44│ 
       45│         # Load package
       46│         name = local_config["name"]
       47│         version = local_config["version"]

After removing the section tool.doesnt.matter.but.triggers.this the configuration of the project is perfectly fine.

This happens for any tool section not part of what poetry uses for its own purposes.

@languitar languitar added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Aug 8, 2022
@radoering
Copy link
Member

Maybe a duplicate of #6135. Can you try updating to tomlkit 0.11.3?

@languitar
Copy link
Author

Yes, this was related to tomlkit and I fixed with 0.11.3, which was now rolled out in Archlinux.

Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

3 participants