go-kratos/kratos · warning
repo URL cannot be empty
Error message
repo URL cannot be empty
What it means
Inline validation in the kratos new interactive form: when the custom repository option is selected, the URL input rejects empty or whitespace-only submissions. The form cannot proceed until a non-empty URL is entered or a preset option is chosen instead.
Source
Thrown at cmd/kratos/internal/project/project.go:190
huh.NewSelect[string]().
Title("Select a template").
Options(
huh.NewOption("Service", "service"),
huh.NewOption("Admin", "admin"),
huh.NewOption("Custom (enter repo URL)", "custom"),
).
Value(&choice),
),
// 2) Input group (only visible when choice == "custom")
huh.NewGroup(
huh.NewInput().
Title("Enter custom repository URL").
Placeholder("https://github.com/owner/repo.git").
Value(&customURL).
Validate(func(s string) error {
s = strings.TrimSpace(s)
if s == "" {
return fmt.Errorf("repo URL cannot be empty")
}
return nil
}),
).WithHideFunc(func() bool {
return choice != "custom"
}),
)
if err := form.Run(); err != nil {
panic(err)
}
if choice == "custom" {
return strings.TrimSpace(customURL), nil
}
return projects[choice], nil
}
View on GitHub (pinned to 668db92c2c)
Solutions
- Type or paste a full git URL (e.g. https://github.com/owner/repo.git) and resubmit
- Switch to a non-custom (preset) repository option instead
Example fix
# before ? Select repo: custom ? Enter custom repository URL: (empty) -> repo URL cannot be empty # after ? Enter custom repository URL: https://github.com/owner/repo.git
Defensive patterns
Strategy: validation
Validate before calling
u := strings.TrimSpace(customURL)
if u == "" {
return errors.New("repo URL cannot be empty")
}
if _, err := url.ParseRequestURI(u); err != nil {
return fmt.Errorf("invalid repo URL: %v", err)
} Prevention
- Default the custom URL field to a template repo you own
- Validate git URLs before invoking the CLI in scripts (CI)
- Prefer non-interactive flags in automation
When it happens
Trigger: Selecting the custom repo choice in the new-project form and submitting with the URL input empty after strings.TrimSpace.
Common situations: User tries to skip the input; clipboard paste fails leaving the field blank; scripted runs hitting the interactive prompt unexpectedly.
Related errors
- unable to parse repo url
- kratos/nacos: ServiceInstance.Name can not be empty
- 🚫 go.mod don't exists in %s
- 🚫 failed to get relative path: %v
- 🚫 failed to parse `go.mod`: %v
AI-assisted analysis of go-kratos/kratos@668db92c2c (2026-08-16).
Data as JSON: /api/errors/fe682a07a57b2230.
Report an issue: GitHub.