{"record":{"id":"741633a62b6959c0","repo":"chenhg5/cc-connect","slug":"begin-failed-w","errorCode":null,"errorMessage":"begin failed: %w","messagePattern":"begin failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cc-connect/feishu.go","lineNumber":562,"sourceCode":"\tvar initRes registrationInitResponse\n\tif err := client.registrationCall(\"init\", nil, &initRes); err != nil {\n\t\treturn nil, fmt.Errorf(\"init failed: %w\", err)\n\t}\n\tif initRes.Error != \"\" {\n\t\treturn nil, fmt.Errorf(\"%s: %s\", initRes.Error, initRes.ErrorDescription)\n\t}\n\tif len(initRes.SupportedAuthMethods) > 0 && !containsString(initRes.SupportedAuthMethods, \"client_secret\") {\n\t\treturn nil, fmt.Errorf(\"current environment does not support client_secret auth\")\n\t}\n\n\tvar beginRes registrationBeginResponse\n\tbeginParams := map[string]string{\n\t\t\"archetype\":         \"PersonalAgent\",\n\t\t\"auth_method\":       \"client_secret\",\n\t\t\"request_user_info\": \"open_id\",\n\t}\n\tif err := client.registrationCall(\"begin\", beginParams, &beginRes); err != nil {\n\t\treturn nil, fmt.Errorf(\"begin failed: %w\", err)\n\t}\n\tif beginRes.Error != \"\" {\n\t\treturn nil, fmt.Errorf(\"%s: %s\", beginRes.Error, beginRes.ErrorDescription)\n\t}\n\tif beginRes.DeviceCode == \"\" || beginRes.VerificationURIComplete == \"\" {\n\t\treturn nil, fmt.Errorf(\"incomplete onboarding response\")\n\t}\n\n\tfmt.Println(\"请使用飞书/Lark 手机 App 扫码完成机器人创建与授权：\")\n\tfmt.Printf(\"URL: %s\\n\\n\", beginRes.VerificationURIComplete)\n\ttryPrintTerminalQRCode(beginRes.VerificationURIComplete)\n\tif opts.QRImagePath != \"\" {\n\t\tif err := saveQRCodeImage(beginRes.VerificationURIComplete, opts.QRImagePath); err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"Warning: failed to save QR image: %v\\n\", err)\n\t\t} else {\n\t\t\tfmt.Printf(\"QR code saved to: %s\\n\\n\", opts.QRImagePath)\n\t\t}\n\t}","sourceCodeStart":544,"sourceCodeEnd":580,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/cmd/cc-connect/feishu.go#L544-L580","documentation":"This error wraps any transport/HTTP failure from the registration service's 'begin' call, which starts the device-code (QR) onboarding session. The %w wrap preserves the underlying cause (network error, non-2xx status, etc.). It means the onboarding session could not even be created.","triggerScenarios":"client.registrationCall(\"begin\", beginParams, &beginRes) returns a non-nil error — e.g. the HTTP POST to the registration endpoint fails, times out, or the server returns an unexpected status handled inside registrationCall.","commonSituations":"No internet connectivity or blocked network during `cc-connect` Feishu setup; corporate proxy/firewall blocking the accounts endpoint; registration service outage or maintenance; misconfigured baseURL pointing at a non-existent host.","solutions":["Check network connectivity to the registration endpoint (try curl to the baseURL) and any proxy settings.","Re-run the setup command — transient network blips are the most common cause.","Verify the configured/derived baseURL for the registration client is correct (feishu vs lark endpoints).","Check Feishu/Lark open-platform status for outages; inspect debug logs (registration debug output) for the exact HTTP failure."],"exampleFix":"// before\n$ cc-connect setup feishu   # fails behind corporate proxy\n// after\n$ export HTTPS_PROXY=http://proxy.corp.local:8080\n$ cc-connect setup feishu","handlingStrategy":"retry","validationCode":"// preflight connectivity\nresp, err := http.Get(registrationBaseURL + \"/health\")\nif err != nil { log.Fatal(\"registration endpoint unreachable: \", err) }\nresp.Body.Close()","typeGuard":null,"tryCatchPattern":"if err := runRegistrationFlow(...); err != nil {\n\tif errors.Is(err, context.DeadlineExceeded) || isNetErr(err) {\n\t\t// exponential backoff retry\n\t}\n\treturn fmt.Errorf(\"feishu setup: %w\", err)\n}","preventionTips":["Verify network/proxy reachability to the registration endpoint before setup.","Configure HTTPS_PROXY explicitly in locked-down corporate environments.","Retry transient failures with backoff instead of assuming permanent failure."],"tags":["network","feishu","registration","http"],"backgroundTag":"api-request-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}