chenhg5/cc-connect · error

invalid --platform-type %q, want feishu or lark

Error message

invalid --platform-type %q, want feishu or lark

What it means

normalizeFeishuPlatformType validates the --platform-type flag for feishu setup. An empty value is allowed (defaults later), but any value other than "feishu" or "lark" (case-insensitive, trimmed) throws this error naming the offending input.

Source

Thrown at cmd/cc-connect/feishu.go:459

	}
	switch len(projects) {
	case 0:
		return "", fmt.Errorf("no project found in config")
	case 1:
		return projects[0], nil
	default:
		sort.Strings(projects)
		return "", fmt.Errorf("multiple projects found, please specify --project (%s)", strings.Join(projects, ", "))
	}
}

func normalizeFeishuPlatformType(raw string) (string, error) {
	raw = strings.ToLower(strings.TrimSpace(raw))
	if raw == "" {
		return "", nil
	}
	if raw != "feishu" && raw != "lark" {
		return "", fmt.Errorf("invalid --platform-type %q, want feishu or lark", raw)
	}
	return raw, nil
}

func validateAppCredentials(appID, appSecret, platformType string) (string, error) {
	appID = strings.TrimSpace(appID)
	appSecret = strings.TrimSpace(appSecret)
	if appID == "" || appSecret == "" {
		return "", errors.New("app_id/app_secret are required")
	}

	candidates := []string{"feishu", "lark"}
	if platformType == "feishu" || platformType == "lark" {
		candidates = []string{platformType}
	}

	var lastErr error
	for _, candidate := range candidates {

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Use --platform-type feishu or --platform-type lark (case-insensitive).
  2. Omit the flag entirely to accept the default.
  3. Fix typos; check the value printed in %q in the error against the two accepted strings.

Example fix

// before
cc-connect feishu setup --platform-type larksuite
// after
cc-connect feishu setup --platform-type lark
Defensive patterns

Strategy: validation

Validate before calling

pt := strings.ToLower(strings.TrimSpace(platformType)); if pt != "" && pt != "feishu" && pt != "lark" { return fmt.Errorf("invalid --platform-type %q", pt) }

Prevention

When it happens

Trigger: Running `cc-connect feishu setup --platform-type something` where something is not feishu/lark, e.g. "Feishu CN", "larksuite", "feishu-lark", or a typo like "feish".

Common situations: Users copying flags from other platform setups; assuming "larksuite" or a region suffix is valid; trailing punctuation from copy-paste is trimmed but a stray word is not.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/14535613fba56f0c. Report an issue: GitHub.