Skip to content

Pending publisher form: a leading space in the project name gives only "Invalid project name", twice #20587

Description

@RonnyPfannschmidt

Written by Claude Opus 5.5 via Claude Code for the PyPI maintainers; I prompted it, it did the work, I read it.

Describe the bug

When adding a pending GitHub trusted publisher, a project name with a leading space ( cot-assert, pasted) is rejected with "Invalid project name" shown twice under the field. The German UI shows "Ungültiger Projektname". Nothing says what is wrong with the name. The name itself is valid: without the space it is accepted.

The message appears twice because two checks reject the same input: the Regexp(PROJECT_NAME_RE) validator on project_name, and validate_project_name, which calls _check_project_name and turns ProjectNameUnavailableInvalidError into the same message (warehouse/oidc/forms/_core.py, warehouse/packaging/services.py).

Expected behavior

Surrounding whitespace is stripped, as the GitHub form already does for workflow_filename (filters=[lambda x: x.strip() if x else x], warehouse/oidc/forms/github.py). Failing that, the message should name the rule the input broke, and show it once.

To Reproduce

  1. Account settings → Publishing → add a pending GitHub publisher.
  2. Enter example-name (with a leading space) as the project name and fill in the other fields.
  3. Submit: "Invalid project name" appears twice, with no further detail.

My Platform

Web UI on pypi.org, German locale.

Additional context

The same filter probably belongs on the other pending-publisher text fields that are validated with a regex (owner, repository), since pasting there hits the same wall.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions