chenhg5/cc-connect · error

app_id and app_secret are required

Error message

app_id and app_secret are required

What it means

Feishu platform credentials consist of an App ID and an App Secret; both must be non-empty after trimming. The function refuses to write a partial credential pair, which would leave the platform entry unusable against the Feishu/Lark API.

Source

Thrown at config/config.go:2030

		PlatformAbsIndex: len(cfg.Projects[len(cfg.Projects)-1].Platforms) - 1,
		PlatformType:     platformType,
	}, nil
}

// SaveFeishuPlatformCredentials updates app_id/app_secret for a project's
// Feishu/Lark platform and persists the config atomically.
func SaveFeishuPlatformCredentials(opts FeishuCredentialUpdateOptions) (*FeishuCredentialUpdateResult, error) {
	configMu.Lock()
	defer configMu.Unlock()

	if ConfigPath == "" {
		return nil, fmt.Errorf("config path not set")
	}
	if strings.TrimSpace(opts.ProjectName) == "" {
		return nil, fmt.Errorf("project name is required")
	}
	if strings.TrimSpace(opts.AppID) == "" || strings.TrimSpace(opts.AppSecret) == "" {
		return nil, fmt.Errorf("app_id and app_secret are required")
	}
	if opts.PlatformIndex < 0 {
		return nil, fmt.Errorf("platform index must be >= 0")
	}
	if opts.PlatformType != "" && opts.PlatformType != "feishu" && opts.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)
	}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Provide both opts.AppID and opts.AppSecret from the Feishu/Lark app credentials page.
  2. Trim whitespace and reject empty values at the caller before calling the function.
  3. Check quoting/escaping when passing the secret via shell or chat message (quotes, env expansion).

Example fix

// before
opts := config.FeishuCredentialUpdateOptions{ProjectName: "p", AppID: "cli_a1b2"} // secret missing

// after
opts := config.FeishuCredentialUpdateOptions{ProjectName: "p", AppID: "cli_a1b2", AppSecret: "xxxx"}
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(appID) == "" || strings.TrimSpace(appSecret) == "" {
    return fmt.Errorf("both app_id and app_secret are required")
}

Prevention

When it happens

Trigger: Calling config.SaveFeishuPlatformCredentials with opts.AppID empty, opts.AppSecret empty, or both (e.g. unset fields, whitespace-only strings, or an incomplete credential collection flow).

Common situations: The user only pasted one of the two values from the Feishu open-platform console; a chat-command parser split the input incorrectly; a secret was lost due to shell quoting or env-var expansion problems.

Related errors


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