chenhg5/cc-connect · error
init failed: %w
Error message
init failed: %w
What it means
runRegistrationFlow starts by calling the registration service's "init" endpoint via registrationCall. Any transport/protocol failure there is wrapped as `init failed: %w`, so the underlying cause (network error, timeout, non-2xx, bad payload) is preserved in the chain.
Source
Thrown at cmd/cc-connect/feishu.go:546
if parsed.Msg != "" {
return false, fmt.Errorf("code=%d msg=%s", parsed.Code, parsed.Msg)
}
return false, nil
}
func runRegistrationFlow(opts registrationFlowOptions) (*registrationFlowResult, error) {
if opts.TimeoutSeconds <= 0 {
opts.TimeoutSeconds = 600
}
client := ®istrationClient{
baseURL: accountsFeishuBaseURL,
http: &http.Client{Timeout: 15 * time.Second},
debug: opts.Debug,
}
var initRes registrationInitResponse
if err := client.registrationCall("init", nil, &initRes); err != nil {
return nil, fmt.Errorf("init failed: %w", err)
}
if initRes.Error != "" {
return nil, fmt.Errorf("%s: %s", initRes.Error, initRes.ErrorDescription)
}
if len(initRes.SupportedAuthMethods) > 0 && !containsString(initRes.SupportedAuthMethods, "client_secret") {
return nil, fmt.Errorf("current environment does not support client_secret auth")
}
var beginRes registrationBeginResponse
beginParams := map[string]string{
"archetype": "PersonalAgent",
"auth_method": "client_secret",
"request_user_info": "open_id",
}
if err := client.registrationCall("begin", beginParams, &beginRes); err != nil {
return nil, fmt.Errorf("begin failed: %w", err)
}
if beginRes.Error != "" {View on GitHub (pinned to 4000b2338a)
Solutions
- Check general internet connectivity and retry the setup command.
- Verify proxy/firewall allows the registration host; set HTTPS_PROXY if needed.
- Re-run after a short wait if it was a transient outage or timeout.
- Unwrap the %w cause in the message for the specific failure (timeout, connection refused, status code).
Defensive patterns
Strategy: retry
Validate before calling
if _, err := http.Head("https://your-registration-host"); err != nil { return fmt.Errorf("registration host unreachable before setup: %w", err) } Try / catch
if err := runFeishuSetup(...); err != nil && strings.HasPrefix(err.Error(), "init failed:") { var netErr net.Error; if errors.As(err, &netErr) && netErr.Timeout() { log.Print("registration init timed out; check network/proxy and retry") } } Prevention
- Verify connectivity and proxy/HTTPS_PROXY settings before running setup.
- Allowlist the registration host in firewalled environments.
- Retry on transient failures; the client uses a 15s timeout.
When it happens
Trigger: The registration service is unreachable, times out (15s HTTP client timeout), returns a non-2xx status, or registrationCall fails to parse the response during runFeishuSetup.
Common situations: No internet or firewalled network during setup; corporate proxy blocking the registration host; transient service outage; DNS failure.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- begin failed: %w
- poll failed: %w
- cloud_web: register request: %w
- remote image HTTP status %d
- first-chunk request: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/594d88e3d206bd99.
Report an issue: GitHub.