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

Invalid author prevents package from being installed #6857

Open
3 tasks done
eblis opened this issue Oct 21, 2022 · 2 comments · May be fixed by python-poetry/poetry-core#517
Open
3 tasks done

Invalid author prevents package from being installed #6857

eblis opened this issue Oct 21, 2022 · 2 comments · May be fixed by python-poetry/poetry-core#517
Assignees
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged
Milestone

Comments

@eblis
Copy link

eblis commented Oct 21, 2022

  • Poetry version: 1.1.12 and 1.2.2

  • Python version: 3.9.13

  • OS version and name: Windows Server 2016 x64

  • I am on the latest stable Poetry version, installed using a recommended method.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • I have consulted the FAQ and blog for any relevant entries or release notes.

  • [x If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

If a package has an invalid author then the package cannot be installed by poetry.
I have a package that has the following author FirstName LastName firstname.lastname@company.com, it's missing the <, > characters from the email part, which prevents poetry from installing it.
Although the author is wrong it shouldn't really prevent the package from being installed, no ? Maybe it should report a warning or something, but continue.
Also, the package isn't reported, so you have no idea which package is the culprit.

  Stack trace:

  9  c:\program files\python39\lib\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  c:\program files\python39\lib\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  c:\program files\python39\lib\site-packages\clikit\api\command\command.py:171 in _do_handle
      169│         handler_method = self._config.handler_method
      170│
    → 171│         return getattr(handler, handler_method)(args, io, self)
      172│
      173│     def __repr__(self):  # type: () -> str

  6  c:\program files\python39\lib\site-packages\cleo\commands\command.py:92 in wrap_handle
       90│         self._command = command
       91│
    →  92│         return self.handle()
       93│
       94│     def handle(self):  # type: () -> Optional[int]

  5  c:\program files\python39\lib\site-packages\poetry\console\commands\install.py:80 in handle
       78│
       79│         try:
    →  80│             builder = EditableBuilder(self.poetry, self._env, self._io)
       81│         except ModuleOrPackageNotFound:
       82│             # This is likely due to the fact that the project is an application

  4  c:\program files\python39\lib\site-packages\poetry\masonry\builders\editable.py:34 in __init__
       32│ class EditableBuilder(Builder):
       33│     def __init__(self, poetry, env, io):
    →  34│         super(EditableBuilder, self).__init__(poetry)
       35│
       36│         self._env = env

  3  c:\program files\python39\lib\site-packages\poetry\core\masonry\builders\builder.py:92 in __init__
       90│         )
       91│
    →  92│         self._meta = Metadata.from_package(self._package)
       93│
       94│     @property

  2  c:\program files\python39\lib\site-packages\poetry\core\masonry\metadata.py:60 in from_package
      58│         meta.keywords = ",".join(package.keywords)
      59│         meta.home_page = package.homepage or package.repository_url
    → 60│         meta.author = package.author_name
      61│         meta.author_email = package.author_email
      62│

  1  c:\program files\python39\lib\site-packages\poetry\core\packages\package.py:173 in author_name
      171│     @property
      172│     def author_name(self):  # type: () -> str
    → 173│         return self._get_author()["name"]
      174│
      175│     @property

  ValueError

  Invalid author string. Must be in the format: John Smith <john@example.com>

  at c:\program files\python39\lib\site-packages\poetry\core\packages\package.py:204 in _get_author
      200│
      201│         m = AUTHOR_REGEX.match(self._authors[0])
      202│
      203│         if m is None:
    → 204│             raise ValueError(
      205│                 "Invalid author string. Must be in the format: "
      206│                 "John Smith <john@example.com>"
      207│             )
      208│
@eblis eblis added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Oct 21, 2022
@eblis
Copy link
Author

eblis commented Oct 21, 2022

I get the same error with Poetry 1.2.2

Stack trace:

  12  C:\Program Files\Python39\lib\site-packages\cleo\application.py:329 in run
       327│
       328│             try:
     → 329│                 exit_code = self._run(io)
       330│             except Exception as e:
       331│                 if not self._catch_exceptions:

  11  C:\Program Files\Python39\lib\site-packages\poetry\console\application.py:185 in _run
       183│         self._load_plugins(io)
       184│
     → 185│         exit_code: int = super()._run(io)
       186│         return exit_code
       187│

  10  C:\Program Files\Python39\lib\site-packages\cleo\application.py:423 in _run
       421│             io.input.set_stream(stream)
       422│
     → 423│         exit_code = self._run_command(command, io)
       424│         self._running_command = None
       425│

   9  C:\Program Files\Python39\lib\site-packages\cleo\application.py:465 in _run_command
       463│
       464│         if error is not None:
     → 465│             raise error
       466│
       467│         return event.exit_code

   8  C:\Program Files\Python39\lib\site-packages\cleo\application.py:449 in _run_command
       447│
       448│             if event.command_should_run():
     → 449│                 exit_code = command.run(io)
       450│             else:
       451│                 exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED

   7  C:\Program Files\Python39\lib\site-packages\cleo\commands\base_command.py:119 in run
       117│         io.input.validate()
       118│
     → 119│         status_code = self.execute(io)
       120│
       121│         if status_code is None:

   6  C:\Program Files\Python39\lib\site-packages\cleo\commands\command.py:83 in execute
        81│
        82│         try:
     →  83│             return self.handle()
        84│         except KeyboardInterrupt:
        85│             return 1

   5  C:\Program Files\Python39\lib\site-packages\poetry\console\commands\install.py:155 in handle
       153│
       154│         try:
     → 155│             builder = EditableBuilder(self.poetry, self.env, self.io)
       156│         except ModuleOrPackageNotFound:
       157│             # This is likely due to the fact that the project is an application

   4  C:\Program Files\Python39\lib\site-packages\poetry\masonry\builders\editable.py:47 in __init__
        45│ class EditableBuilder(Builder):
        46│     def __init__(self, poetry: Poetry, env: Env, io: IO) -> None:
     →  47│         super().__init__(poetry)
        48│
        49│         self._env = env

   3  C:\Program Files\Python39\lib\site-packages\poetry\core\masonry\builders\builder.py:90 in __init__
        88│         )
        89│
     →  90│         self._meta = Metadata.from_package(self._package)
        91│
        92│     @property

   2  C:\Program Files\Python39\lib\site-packages\poetry\core\masonry\metadata.py:66 in from_package
        64│         meta.keywords = ",".join(package.keywords)
        65│         meta.home_page = package.homepage or package.repository_url
     →  66│         meta.author = package.author_name
        67│         meta.author_email = package.author_email
        68│

   1  C:\Program Files\Python39\lib\site-packages\poetry\core\packages\package.py:172 in author_name
       170│     @property
       171│     def author_name(self) -> str | None:
     → 172│         return self._get_author()["name"]
       173│
       174│     @property

  ValueError

  Invalid author string. Must be in the format: John Smith <john@example.com>

  at C:\Program Files\Python39\lib\site-packages\poetry\core\packages\package.py:232 in _get_author
      228│
      229│         m = AUTHOR_REGEX.match(self._authors[0])
      230│
      231│         if m is None:
    → 232│             raise ValueError(
      233│                 "Invalid author string. Must be in the format: "
      234│                 "John Smith <john@example.com>"

@eblis
Copy link
Author

eblis commented Oct 21, 2022

The project i was actually working on didn't have a correct email address, which lead to the problem.
I was able to add the <> characters, but the error should at least report which package it's referring to. And ideally it shouldn't crash, just report the warning

@Secrus Secrus self-assigned this Oct 6, 2024
@Secrus Secrus added this to the Poetry 2.0 milestone Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants