Validate repository names during interactive creation - #14313
Merged
Conversation
Interactive gh repo create previously accepted an empty repository name and continued through owner, description, visibility, initialization, and confirmation prompts. The command only rejected the resulting owner/ value when constructing the repository reference, forcing users to repeat the entire workflow. Update interactive repository information collection to receive IOStreams so repository-name validation can report feedback at the point of entry. Retry the Repository name prompt while the submitted value is empty or contains only whitespace, and print the standard failure icon with a clear Repository name cannot be blank message after each invalid response. Pass IOStreams through all interactive creation paths, including repositories created from scratch, from templates, and from local repositories. Valid names continue through the existing owner parsing and organization selection behavior unchanged. Add a focused regression test that submits a whitespace-only name, verifies the prompt is repeated, then confirms a qualified OWNER/REPO response is parsed correctly and the validation message is written to stderr. Fixes #14297 Co-authored-by: Copilot <[email protected]> Copilot-Session: f1c97983-6a41-4a95-b708-30a5c33d10bc
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused implementation matches the reported behavior and includes appropriate regression coverage.
Review tier: Balanced
Findings: None
What changed in this PR
Validates blank repository names early in interactive gh repo create flows.
Changes:
- Re-prompts for empty or whitespace-only names with immediate feedback.
- Routes existing IO streams through all interactive creation paths.
- Adds coverage for retrying and qualified owner/name parsing.
| File | Description |
|---|---|
pkg/cmd/repo/create/create.go |
Adds centralized interactive name validation. |
pkg/cmd/repo/create/create_test.go |
Tests blank-name feedback and retry behavior. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
tidy-dev
approved these changes
Sep 3, 2026
tidy-dev
left a comment
Contributor
There was a problem hiding this comment.
✨ Works as expected.
Also had Copilot generate 32 permutations of this command non-inclusive of this change with no apparent regressions.
BagToad
reviewed
Sep 5, 2026
BagToad
reviewed
Sep 5, 2026
Blank repository names no longer trigger a re-prompt loop; interactiveRepoNameAndOwner now returns an error immediately, simplifying the function signature (drops the unused *iostreams.IOStreams param) and making create fail fast with a clear message. Updated tests accordingly. Co-Authored-By: Kynan Ware <[email protected]>
BagToad
approved these changes
Sep 9, 2026
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.
Fixes #14297
Description
Interactive
gh repo createaccepted an empty repository name and continued through every remaining prompt. The command only failed after confirmation, when it tried to parse the incompleteOWNER/repository reference. Users then had to restart the full creation flow.This change validates the repository name immediately after input. Empty and whitespace-only values now stop the interactive flow with
repository name cannot be blank, before owner, description, visibility, initialization, or confirmation prompts are shown.Validation remains centralized beside repository-name parsing, so creating from scratch, from a template, and from a local repository all reject blank names consistently without additional I/O plumbing.
How did you test this change?
Added
Test_createRuncases for empty and whitespace-only names. Both verify that validation fails immediately and produces no command output before the returned error is rendered by the command layer.Key points
Blank-name validation runs immediately after the repository-name prompt and before owner parsing or later interactive prompts.
Whitespace-only input is treated as blank. Valid input is otherwise preserved and passed to existing parsing unchanged.
Notes for reviewers
Start with
interactiveRepoNameAndOwnerinpkg/cmd/repo/create/create.go, then review theinteractive create from scratch with empty nameandinteractive create from scratch with whitespace-only namecases inpkg/cmd/repo/create/create_test.go.The tests cover both invalid forms, immediate termination, the returned error, and empty stdout and stderr at the
createRunlayer.Authorship and follow-up
Who wrote this:
Who answers review comments: