python-poetry/poetry · error · ValueError
Invalid author string. Must be in the format: John Smith <jo
Error message
Invalid author string. Must be in the format: John Smith <john@example.com>
What it means
ValueError from `_validate_author` (init.py:508-513) when the author string (after unicode combining) does not match `AUTHOR_REGEX`, which expects `Name <email>`. Used by `poetry init` to populate `authors` in pyproject.toml.
Source
Thrown at src/poetry/console/commands/init.py:510
constraint.update(requirement)
requires[name] = constraint
return requires
@staticmethod
def _validate_author(author: str, default: str) -> str | None:
from poetry.core.utils.helpers import combine_unicode
from poetry.core.utils.patterns import AUTHOR_REGEX
author = combine_unicode(author or default)
if author in ["n", "no"]:
return None
m = AUTHOR_REGEX.match(author)
if not m:
raise ValueError(
"Invalid author string. Must be in the format: "
"John Smith <john@example.com>"
)
return author
@staticmethod
def _validate_package(package: str | None) -> str | None:
if package and len(package.split()) > 2:
raise ValueError("Invalid package definition.")
return package
@staticmethod
def _validate_version_constraint(constraint: str | None) -> str | None:
from poetry.core.constraints.version import parse_constraint
constraint = (constraint or "").strip()View on GitHub (pinned to 92b74dcfe3)
Solutions
- Use the exact format `John Smith <john@example.com>`.
- Omit authors by entering `n` or `no` at the prompt.
- For non-ASCII names, ensure the terminal is UTF-8 and the combined form still matches `Name <email>`.
Example fix
# before John Smith, john@example.com # after John Smith <john@example.com>
Defensive patterns
Strategy: validation
Validate before calling
import re
from poetry.core.utils.patterns import AUTHOR_REGEX
from poetry.core.utils.helpers import combine_unicode
author = combine_unicode("John Smith <john@example.com>")
if not AUTHOR_REGEX.match(author):
raise SystemExit("author must be 'Name <email>'") Type guard
def is_valid_author(value: str) -> bool:
from poetry.core.utils.patterns import AUTHOR_REGEX
from poetry.core.utils.helpers import combine_unicode
return bool(AUTHOR_REGEX.match(combine_unicode(value or ""))) Prevention
- Always include both display name and angle-bracketed email.
- Enter `n`/`no` to skip authors.
- For non-ASCII names, test the combined form through `AUTHOR_REGEX`.
When it happens
Trigger: Entering `John Smith` without an email; `john@example.com` without a name; reversed order `john@example.com (John Smith)`; embedded newline or stray characters.
Common situations: Skipping the email during interactive init; pasting from a vCard; non-ASCII names that break the regex after `combine_unicode`.
Related errors
- Invalid package definition.
- Invalid version constraint: {constraint}
- Setting {self.argument('key')} does not exist
- You can only pass one value.
- "{value}" is an invalid value for {key}
AI-assisted analysis of python-poetry/poetry@92b74dcfe3 (2026-08-04).
Data as JSON: /data/errors/730963aef4a4350c.json.
Report an issue: GitHub.