Clarify npm and pip package name validation errors#31822
Merged
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Extend npm/pip package name validation error messages
Clarify npm and pip package name validation errors
May 13, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances npm and pip package-name validation errors to include inline rule guidance and canonical examples, and updates tests to assert the improved user-facing error text.
Changes:
- Expanded
validateNpmPackageNameandvalidatePipPackageNameerror messages with rule summaries and examples. - Updated existing validator tests to assert both the rejected value and the new guidance text.
- Updated the generated
.github/workflows/agentic_commands.ymlheader metadata (compiler_version).
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/name_validation.go | Improves npm/PyPI validation error strings with rule + example guidance. |
| pkg/workflow/argument_injection_test.go | Strengthens assertions to ensure errors include both the invalid value and guidance text. |
| .github/workflows/agentic_commands.yml | Regenerated workflow header (compiler_version). |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
pkg/workflow/argument_injection_test.go:360
- The same long expected PyPI guidance string is duplicated across multiple test cases. Consider factoring it into a single const/var used by all invalid-case entries to keep the table concise and reduce maintenance overhead if the wording changes.
{
name: "name starting with hyphen is rejected",
pkg: "--index-url=https://attacker.example",
expectError: true,
errContains: "PyPI names must start and end with a letter or digit, with hyphens, underscores, or dots allowed inside (e.g. \"requests\" or \"my-package\")",
},
- Files reviewed: 3/3 changed files
- Comments generated: 3
| if !npmPackageNameRE.MatchString(pkg) { | ||
| nameValidationLog.Printf("Invalid npm package name: %s", pkg) | ||
| return fmt.Errorf("invalid npm package name: %q", pkg) | ||
| return fmt.Errorf("invalid npm package name: %q — npm names must be lowercase alphanumeric and may include hyphens, dots, and underscores (e.g. \"my-package\" or \"@scope/name\")", pkg) |
Comment on lines
265
to
270
| { | ||
| name: "name starting with hyphen is rejected", | ||
| pkg: "--registry=https://attacker.example", | ||
| expectError: true, | ||
| errContains: "invalid npm package name", | ||
| errContains: "npm names must be lowercase alphanumeric and may include hyphens, dots, and underscores (e.g. \"my-package\" or \"@scope/name\")", | ||
| }, |
| @@ -1,4 +1,4 @@ | |||
| # gh-aw-commands: {"payload_version":"v1","schema_version":"v1","compiler_version":"26ba207","commands":["ace","approach-validator","archie","brave","cloclo","craft","grumpy","mergefest","nit","plan","poem-bot","review","security-review","summarize","tidy","unbloat"],"workflows":["ace-editor","approach-validator","archie","brave","cloclo","craft","grumpy-reviewer","mergefest","pdf-summary","plan","poem-bot","pr-code-quality-reviewer","pr-nitpick-reviewer","security-review","tidy","unbloat-docs"]} | |||
| # gh-aw-commands: {"payload_version":"v1","schema_version":"v1","compiler_version":"26cb048","commands":["ace","approach-validator","archie","brave","cloclo","craft","grumpy","mergefest","nit","plan","poem-bot","review","security-review","summarize","tidy","unbloat"],"workflows":["ace-editor","approach-validator","archie","brave","cloclo","craft","grumpy-reviewer","mergefest","pdf-summary","plan","poem-bot","pr-code-quality-reviewer","pr-nitpick-reviewer","security-review","tidy","unbloat-docs"]} | |||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✨ Enhancement
Invalid npm/pip package names currently fail with value-only errors, which force workflow authors to look up naming rules elsewhere. This updates those validation errors to explain the constraint inline and show a canonical valid example.
What does this improve?
Why is this valuable?
Implementation approach:
pkg/workflow/name_validation.goto expand the npm and PyPI error strings with format rules and examples.pkg/workflow/argument_injection_test.goto verify: