parse_maintainer_name_email returns empty name and wrong email when string has "@" but no angle brackets
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
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
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
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from aboutcode-org/scancode-toolkit
-
yarn.lock v1 with a scoped alias of an unscoped package yields no packages and no errorPossibly taken @Shubham-dev-stack claimed this 6 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
aboutcode-org/scancode-toolkit#5466 ·
Maintainers usually reply within 2 days
-
package-lock.json dependencies report file_references as a list inside a listPossibly taken @Anbarasu2410 claimed this 9 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
aboutcode-org/scancode-toolkit#5449 · 4 comments ·
Maintainers usually reply within 2 days
-
scancode aborts when encountering a broken RPM archivePossibly taken @Ashutosh-Panda2004 claimed this 14 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
aboutcode-org/scancode-toolkit#5407 · 3 comments ·
Maintainers usually reply within 2 days
-
Four silent bugs: IsRequiredPhrase.license_expression returns None, find_in_path ignores later PATH changes, duplicate dict keys override license mappingsPossibly taken A pull request linked to this issue is open or already merged. Openbug
Difficulty 2/5 Half a day Newbie friendliness 65/100
aboutcode-org/scancode-toolkit#5405 · 1 comment ·
Maintainers usually reply within 2 days
-
bug: Unreachable JSON extension and format validation in validate_input_pathPossibly taken @0Cymantek0 claimed this 38 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
aboutcode-org/scancode-toolkit#5351 · 1 comment ·
Maintainers usually reply within 2 days
All issues in aboutcode-org/scancode-toolkit
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
mohanraj00/entelos#200 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
sweep
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
bketelsen/truenas-mcp#77 ·
Maintainers usually reply within 1 day
-
Console writes URL credentials to the local log, though AGENTS.md says secrets never reach diskOpen
Difficulty 1/5 Under an hour Newbie friendliness 86/100
sandbox-quantum/switch#2163 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
openedx/xblock-lti-consumer#765 ·
Maintainers usually reply within 1 day