chenhg5/cc-connect · error

remote returned non-zero code

Error message

remote returned non-zero code

What it means

validateAppCredentials tries each candidate base URL by calling validateAppCredentialsAgainstBase (a tenant_token request). When a candidate responds but the credential check does not succeed (ok==false) and no more specific error was propagated, it records "remote returned non-zero code" and moves on; if every candidate fails this way, this is the error the user sees.

Source

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

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

	var lastErr error
	for _, candidate := range candidates {
		base := openFeishuBaseURL
		if candidate == "lark" {
			base = openLarkBaseURL
		}
		ok, err := validateAppCredentialsAgainstBase(base, appID, appSecret)
		if err != nil {
			lastErr = err
			continue
		}
		if ok {
			return candidate, nil
		}
		lastErr = fmt.Errorf("remote returned non-zero code")
	}
	if lastErr == nil {
		lastErr = fmt.Errorf("unknown validation error")
	}
	return "", lastErr
}

func validateAppCredentialsAgainstBase(baseURL, appID, appSecret string) (bool, error) {
	body, _ := json.Marshal(map[string]string{
		"app_id":     appID,
		"app_secret": appSecret,
	})
	req, err := http.NewRequest(http.MethodPost, baseURL+"/open-apis/auth/v3/tenant_access_token/internal", bytes.NewReader(body))
	if err != nil {
		return false, err
	}
	req.Header.Set("Content-Type", "application/json")

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Re-check app_id and app_secret against the Feishu/Lark open platform console.
  2. Confirm --platform-type matches the app's region (feishu vs lark) so the correct base URL is tried.
  3. Ensure the app is enabled/published and has permission to issue tenant_access_token.
  4. If a more specific "code=... msg=..." error appears instead, act on that message.
Defensive patterns

Strategy: retry

Validate before calling

if !strings.Contains(appID, "cli_") || len(appSecret) < 8 { return errors.New("app id/secret look malformed before calling remote validation") }

Try / catch

if err := runFeishuSetup(...); err != nil && strings.Contains(err.Error(), "remote returned non-zero code") { log.Printf("credential rejected by Feishu: %v; verify app_id/app_secret and region", err) }

Prevention

When it happens

Trigger: The Feishu/Lark auth endpoint answered with HTTP 200 but the tenant_token response carried a non-zero code (invalid app_id/app_secret), or validateAppCredentialsAgainstBase returned ok=false without a message.

Common situations: Typo in app secret; using a Lark (larksuite) app ID against the Feishu base URL or vice versa; app not yet published/enabled; secret rotated recently.

Related errors


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