poetry: Poetry fails with intenral error on malformed author

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Windows 10
  • Poetry version: 0.12.16
  • Link of a Gist with the contents of your pyproject.toml file:

Issue

I didn’t pay attention to the format of the authors field and just typed in “name@domain.com” and got the following failure

[AttributeError]
'NoneType' object has no attribute 'group'

Exception trace:
 p:\.venv\lib\site-packages\cleo\application.py in run() at line 94
   status_code = self.do_run(input_, output_)
 p:\.venv\lib\site-packages\poetry\console\application.py in do_run() at line 88
   return super(Application, self).do_run(i, o)
 p:\.venv\lib\site-packages\cleo\application.py in do_run() at line 197
   status_code = command.run(input_, output_)
 p:\.venv\lib\site-packages\poetry\console\commands\command.py in run() at line 77
   return super(BaseCommand, self).run(i, o)
 p:\.venv\lib\site-packages\cleo\commands\base_command.py in run() at line 146
   status_code = self.execute(input_, output_)
 p:\.venv\lib\site-packages\cleo\commands\command.py in execute() at line 107
   return self.handle()
 p:\.venv\lib\site-packages\poetry\console\commands\install.py in handle() at line 61
   builder = EditableBuilder(self.poetry, self._env, NullIO())
 p:\.venv\lib\site-packages\poetry\masonry\builders\builder.py in __init__() at line 50
   self._meta = Metadata.from_package(self._package)
 p:\.venv\lib\site-packages\poetry\masonry\metadata.py in from_package() at line 54
   meta.author = package.author_name
 p:\.venv\lib\site-packages\poetry\packages\package.py in author_name() at line 130
   return self._get_author()["name"]
 p:\.venv\lib\site-packages\poetry\packages\package.py in _get_author() at line 146
   name = m.group("name")

install [--no-dev] [--dry-run] [-E|--extras EXTRAS] [--develop DEVELOP]

What I’d expect

  • An error saying that the field is malformed
  • poetry check to report this error as well.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 19 (12 by maintainers)

Most upvoted comments

Yes and not: run does not implies install, but it can look into the pyproject.toml scripts directly:

Knowing poetry was inspired by cargo is why I felt this behavior was surprising. In cargo, I can just type cargo run and it will prepare everything for running, including

  • Ensuring the lock file is not out of sync with the manifest file
  • Ensure deps are processed
  • Ensure it is runnable

So it was surprising when I typed poetry run and it didn’t install all of my deps into the venv. I think I’ve also seen warnings about my lock file being out of date, so it seems it also doesn’t implicitly sync the lock file with the manifest file.

Also, issue about author field already exists (#370).

I missed that, thanks! How much they are a dup is a question of how someone fixes 370. In that one, the user put in a character that should be valid but instead failed. This could just be fixed by updating the parser without impacting the error reporting. In this one, I put in an invalid author and the error was not helpful.

Personally, I think three things need to be done

  • Update the parser
  • Ensure a good error is reported
  • Ensure the error is returned by poetry check

I was now able to reproduce it. I’m with @epage that poetry check should report this as well.

I further think, that the method, that do the validation, should also check the validation/presents of more mandatory fields and this should be called every time before poetry starts any action where a valid pyproject.toml is needed.

I could work on this. What do you think @sdispater, @stephsamson ?

authors = ["xxx/x"]

resulted in

[AttributeError]
'NoneType' object has no attribute 'group'

not very user-friendly.

I have the same problem. In Poetry 1.0.2, just write this, the problem goes away:

authors = []

Why is authors a required field? If has no influence on the software I’m trying to build.

I was on 1.0.0b2, it does appear to be happening under b3 as well:

$ poetry install
Installing dependencies from lock file

Nothing to install or update


[AttributeError]
'NoneType' object has no attribute 'group'

Same pyproject.toml as above, errors with foo@bar.com but not Foo <foo@bar.com>. Happens under Python 3.7 and 3.8.