parse_maintainer_name_email returns empty name and wrong email when string has "@" but no angle brackets

Open Beginner friendly
#5,402 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@RohitSutar1823 is already working on this.

Since Nov 4, 2026.

  • #5412 by @RohitSutar1823 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

The bug is in the has_email check inside parse_maintainer_name_email() in src/packagedcode/utils.py. Its callers in debian.py and pypi.py pass in maintainer strings. Run the three reproduction examples from the issue to see the current output. Done when a string without both brackets returns no email, the Debian systemd example still parses, and the existing tests for these parsers still pass. Check the expected output for the <[email protected] case, since the issue's expectation there may need confirming.

Written by the indexing model from the issue text.

Description

bug

parse_maintainer_name_email() in src/packagedcode/utils.py is meant to
split Name <email> strings. It should only extract an email when both <
and > are present. The check is wrong:

has_email = "@" in maintainer and all([
    True
    for char in email_wrappers
    if char in maintainer
])

The list only holds the brackets that are present. If neither bracket is
present it is [], and all([]) is True. If only one is present it is
[True], also True. So any string containing @ is treated as Name <email>.

With no <, maintainer.rpartition("<") returns ('', '', maintainer).
The name becomes an empty string and the whole string is saved as the email.

This affects Debian maintainers and uploaders (debian.py) and
pyproject.toml authors and maintainers (pypi.py).

How To Reproduce
from packagedcode.utils import parse_maintainer_name_email

parse_maintainer_name_email("John Doe [email protected]")
# actual:   ('', 'John Doe [email protected]')
# expected: ('John Doe [email protected]', None)

parse_maintainer_name_email("John Doe <[email protected]")
# actual:   ('John Doe', '[email protected]')
# expected: ('John Doe <[email protected]', None)

parse_maintainer_name_email("Debian systemd Maintainers <[email protected]>")
# works correctly, unchanged
Suggested fix
has_email = "@" in maintainer and all(
    char in maintainer
    for char in email_wrappers
)
Dominant language
Python
Stars
2.7k
Forks
871
Avg merge
1d 10h
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aboutcode-org/scancode-toolkit

All issues in aboutcode-org/scancode-toolkit

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.