{"record":{"id":"a12315b7f09bb431","repo":"chenhg5/cc-connect","slug":"remote-returned-non-zero-code","errorCode":null,"errorMessage":"remote returned non-zero code","messagePattern":"remote returned non-zero code","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cc-connect/feishu.go","lineNumber":490,"sourceCode":"\tif platformType == \"feishu\" || platformType == \"lark\" {\n\t\tcandidates = []string{platformType}\n\t}\n\n\tvar lastErr error\n\tfor _, candidate := range candidates {\n\t\tbase := openFeishuBaseURL\n\t\tif candidate == \"lark\" {\n\t\t\tbase = openLarkBaseURL\n\t\t}\n\t\tok, err := validateAppCredentialsAgainstBase(base, appID, appSecret)\n\t\tif err != nil {\n\t\t\tlastErr = err\n\t\t\tcontinue\n\t\t}\n\t\tif ok {\n\t\t\treturn candidate, nil\n\t\t}\n\t\tlastErr = fmt.Errorf(\"remote returned non-zero code\")\n\t}\n\tif lastErr == nil {\n\t\tlastErr = fmt.Errorf(\"unknown validation error\")\n\t}\n\treturn \"\", lastErr\n}\n\nfunc validateAppCredentialsAgainstBase(baseURL, appID, appSecret string) (bool, error) {\n\tbody, _ := json.Marshal(map[string]string{\n\t\t\"app_id\":     appID,\n\t\t\"app_secret\": appSecret,\n\t})\n\treq, err := http.NewRequest(http.MethodPost, baseURL+\"/open-apis/auth/v3/tenant_access_token/internal\", bytes.NewReader(body))\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n","sourceCodeStart":472,"sourceCodeEnd":508,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/cmd/cc-connect/feishu.go#L472-L508","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-check app_id and app_secret against the Feishu/Lark open platform console.","Confirm --platform-type matches the app's region (feishu vs lark) so the correct base URL is tried.","Ensure the app is enabled/published and has permission to issue tenant_access_token.","If a more specific \"code=... msg=...\" error appears instead, act on that message."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if !strings.Contains(appID, \"cli_\") || len(appSecret) < 8 { return errors.New(\"app id/secret look malformed before calling remote validation\") }","typeGuard":null,"tryCatchPattern":"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) }","preventionTips":["Verify app_id/app_secret in the Feishu/Lark console before running setup.","Match --platform-type to the app's actual region (feishu vs lark).","Keep the app enabled and published so token issuance succeeds.","Re-run setup after rotating the secret."],"tags":["feishu","authentication","credentials","network"],"backgroundTag":"authentication-required","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}