gastownhall/beads · error

remote name must not start with a dash

Error message

remote name must not start with a dash

What it means

A remote name starting with '-' would be interpreted as a CLI flag by flag-parsing code, enabling argument-injection mistakes. ValidateRemoteName rejects leading dashes explicitly before the regex check runs.

Source

Thrown at internal/remotecache/url.go:200

	colonIdx := strings.Index(rawURL[atIdx:], ":")
	if atIdx < 0 || colonIdx < 0 {
		return fmt.Errorf("SCP-style URL must be in user@host:path format")
	}
	return nil
}

// ValidateRemoteName checks that a remote name is safe for use as a Dolt
// remote identifier. Names must start with a letter and contain only
// alphanumeric characters, hyphens, and underscores. Max 64 characters.
func ValidateRemoteName(name string) error {
	if name == "" {
		return fmt.Errorf("remote name cannot be empty")
	}
	if len(name) > 64 {
		return fmt.Errorf("remote name too long (max 64 characters)")
	}
	if strings.HasPrefix(name, "-") {
		return fmt.Errorf("remote name must not start with a dash")
	}
	if !validRemoteNameRegex.MatchString(name) {
		return fmt.Errorf("remote name must start with a letter and contain only alphanumeric characters, hyphens, and underscores")
	}
	return nil
}

// MatchesRemotePattern checks whether a URL matches a glob-style pattern.
// Patterns use path.Match semantics (e.g., "dolthub://myorg/*").
func MatchesRemotePattern(rawURL, pattern string) bool {
	matched, err := path.Match(pattern, rawURL)
	if err != nil {
		return false
	}
	return matched
}

// ValidateRemoteURLWithPatterns validates a URL and optionally checks it

View on GitHub (pinned to 71377f2769)

Solutions

  1. Remove the leading dash or prefix the name with a letter (e.g. 'remote-foo').
  2. Audit scripts for variables that may begin with '-' and quote/validate before passing.
  3. Pick an alphanumeric-first alias such as 'origin' or 'upstream'.

Example fix

// before
ValidateRemoteName("-staging")
// after
ValidateRemoteName("staging")
Defensive patterns

Strategy: validation

Validate before calling

if strings.HasPrefix(name, "-") {
    return fmt.Errorf("remote name must not start with a dash")
}

Try / catch

if err := remotecache.ValidateRemoteName(name); err != nil {
    return fmt.Errorf("invalid remote name %q: %w", name, err)
}

Prevention

When it happens

Trigger: Calling ValidateRemoteName("-foo") or passing a name beginning with '-' to remote-adding flows, e.g. `bd remote add --name -weird <url>` or a variable that accidentally contains a dash-prefixed token.

Common situations: Scripts that concatenate flags into a name variable; users typing a dash by habit; names copied from diff/commit ranges like '-main'.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/58b39e8174c71e31. Report an issue: GitHub.