multica-ai/multica · warning

repository URL cannot be empty

Error message

repository URL cannot be empty

What it means

Returned by `repoURLsFromArgsAndFlags` when a supplied repository URL trims to an empty string (`strings.TrimSpace(u) == ""`). Unlike the 'at least one' check, this fires when a URL slot exists but its content is blank — including whitespace-only values.

Source

Thrown at server/cmd/multica/cmd_repo.go:111

	Updated     []workspaceRepo `json:"updated,omitempty"`
	Removed     []workspaceRepo `json:"removed,omitempty"`
	Repos       []workspaceRepo `json:"repos"`
}

func repoURLsFromArgsAndFlags(cmd *cobra.Command, args []string) ([]string, error) {
	flagURLs, _ := cmd.Flags().GetStringArray("url")
	raw := append([]string{}, flagURLs...)
	raw = append(raw, args...)
	if len(raw) == 0 {
		return nil, fmt.Errorf("at least one repository URL is required")
	}

	urls := make([]string, 0, len(raw))
	seen := make(map[string]struct{}, len(raw))
	for _, u := range raw {
		u = strings.TrimSpace(u)
		if u == "" {
			return nil, fmt.Errorf("repository URL cannot be empty")
		}
		if _, ok := seen[u]; ok {
			continue
		}
		seen[u] = struct{}{}
		urls = append(urls, u)
	}
	return urls, nil
}

func fetchRepoWorkspace(ctx context.Context, client *cli.APIClient, workspaceID string) (repoWorkspaceResponse, error) {
	var ws repoWorkspaceResponse
	if err := client.GetJSON(ctx, "/api/workspaces/"+workspaceID, &ws); err != nil {
		return repoWorkspaceResponse{}, fmt.Errorf("get workspace: %w", err)
	}
	if ws.Repos == nil {
		ws.Repos = []workspaceRepo{}
	}

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Remove empty/whitespace entries from the arguments or `--url` flags.
  2. Filter the list in the calling script: `URLS=$(grep -v '^[[:space:]]*$' repos.txt`).
  3. Validate each URL is non-empty and starts with the expected scheme (https://) before invoking the CLI.

Example fix

# before
REPOS=("" "https://github.com/acme/api")
for r in "${REPOS[@]}"; do multica repo add "$r"; done
# error: repository URL cannot be empty

# after
for r in "${REPOS[@]}"; do [ -z "$(printf '%s' "$r" | tr -d '[:space:]')" ] && continue; multica repo add "$r"; done
Defensive patterns

Strategy: validation

Validate before calling

# bash: strip empty/whitespace entries before invoking
mapfile -t REPOS < <(grep -v '^[[:space:]]*$' repos.txt)
multica repo add "${REPOS[@]}"

Type guard

func isNonEmptyURL(u string) bool { return strings.TrimSpace(u) != "" }

Prevention

When it happens

Trigger: Passing `--url ""`, `--url " "`, or an empty positional arg (common with quoted empty shell variables or trailing spaces in generated lists).

Common situations: Scripts looping over a repo array that contains an empty element (`for r in "${REPOS[@]}"` with an empty entry); copy-paste leaving a stray `''` argument; whitespace artifacts from file reads.

Related errors


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/f77f763c3f515ed9. Report an issue: GitHub.