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

The platform type argument is validated against the two supported values, "feishu" and "lark" (case-insensitive; empty defaults to "feishu"). Any other string is rejected with the original (untrimmed, un-lowercased) value quoted, so callers know exactly what they passed.

Source

Thrown at config/config.go:1913

// written immediately.
func EnsureProjectWithFeishuPlatform(opts EnsureProjectWithFeishuOptions) (*EnsureProjectWithFeishuResult, error) {
	configMu.Lock()
	defer configMu.Unlock()

	if ConfigPath == "" {
		return nil, fmt.Errorf("config path not set")
	}
	projectName := strings.TrimSpace(opts.ProjectName)
	if projectName == "" {
		return nil, fmt.Errorf("project name is required")
	}

	platformType := strings.ToLower(strings.TrimSpace(opts.PlatformType))
	if platformType == "" {
		platformType = "feishu"
	}
	if platformType != "feishu" && platformType != "lark" {
		return nil, fmt.Errorf("invalid platform type %q (want feishu or lark)", opts.PlatformType)
	}

	data, err := os.ReadFile(ConfigPath)
	if err != nil {
		return nil, fmt.Errorf("read config: %w", err)
	}
	raw := string(data)
	cfg := &Config{}
	if err := toml.Unmarshal(data, cfg); err != nil {
		return nil, fmt.Errorf("parse config: %w", err)
	}

	for i := range cfg.Projects {
		if cfg.Projects[i].Name != projectName {
			continue
		}
		platformIdx := firstFeishuPlatformIndex(cfg.Projects[i].Platforms)
		added := false

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Set opts.PlatformType to exactly "feishu" or "lark" (case does not matter).
  2. Leave opts.PlatformType empty to get the default "feishu".
  3. Normalize the value at the caller with strings.ToLower(strings.TrimSpace(...)) and match against the two allowed values before calling.

Example fix

// before
opts := config.EnsureProjectWithFeishuOptions{ProjectName: "p", PlatformType: "larksuite"}

// after
opts := config.EnsureProjectWithFeishuOptions{ProjectName: "p", PlatformType: "lark"}
Defensive patterns

Strategy: validation

Validate before calling

pt := strings.ToLower(strings.TrimSpace(opts.PlatformType))
if pt != "" && pt != "feishu" && pt != "lark" {
    return fmt.Errorf("unsupported platform type %q", opts.PlatformType)
}

Prevention

When it happens

Trigger: Calling config.EnsureProjectWithFeishuPlatform with opts.PlatformType set to anything other than "feishu"/"lark" in any casing, e.g. "Feishu cloud", "larksuite", "feishu_cn", or a typo like "fieshu".

Common situations: Typing the platform name by hand in a config-generation tool; using "larksuite" assuming it is a synonym; copying a platform slug from another project that uses different naming.

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/451594421642a4f1. Report an issue: GitHub.