chenhg5/cc-connect · error

unknown validation error

Error message

unknown validation error

What it means

validateAppCredentials falls back to "unknown validation error" when the candidate loop ends with lastErr == nil, i.e. no candidate produced a definitive success or failure. This is a defensive placeholder indicating the validation loop never actually attempted a check.

Source

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

	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")

	client := &http.Client{Timeout: 10 * time.Second}
	resp, err := client.Do(req)
	if err != nil {

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Re-run with --debug if available to see which base URLs were attempted.
  2. Explicitly pass --platform-type feishu or lark so a valid candidate base URL is generated.
  3. Check network/proxy settings; if requests fail before producing an error the loop may never set lastErr.
  4. If reproducible, report as a bug — this message signals an unhandled path in validateAppCredentials.
Defensive patterns

Strategy: fallback

Validate before calling

if platformType == "" { platformType = "feishu" } // ensure a candidate base URL exists before validation

Try / catch

if err != nil && strings.Contains(err.Error(), "unknown validation error") { log.Printf("validation loop produced no attempt; re-run with explicit --platform-type and debug enabled") }

Prevention

When it happens

Trigger: The candidate base URL list was empty, or every iteration hit the `continue` path without setting lastErr (an edge case in how candidates/errors are collected), leaving lastErr nil after the loop.

Common situations: Misconfigured or empty platform-type/base-URL candidate derivation; an internal edge case rather than a user-input mistake.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — 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/9277fbd74db49946. Report an issue: GitHub.