{"record":{"id":"a9978c3cffe63cd5","repo":"charmbracelet/crush","slug":"failed-to-get-init-prompt-w","errorCode":null,"errorMessage":"failed to get init prompt: %w","messagePattern":"failed to get init prompt: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/client/config.go","lineNumber":204,"sourceCode":"// server.\nfunc (c *Client) MarkProjectInitialized(ctx context.Context, id string) error {\n\trsp, err := c.post(ctx, fmt.Sprintf(\"/workspaces/%s/project/init\", id), nil, nil, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to mark project initialized: %w\", err)\n\t}\n\tdefer rsp.Body.Close()\n\tif rsp.StatusCode != http.StatusOK {\n\t\treturn fmt.Errorf(\"failed to mark project initialized: status code %d\", rsp.StatusCode)\n\t}\n\treturn nil\n}\n\n// GetInitializePrompt retrieves the initialization prompt from the\n// server.\nfunc (c *Client) GetInitializePrompt(ctx context.Context, id string) (string, error) {\n\trsp, err := c.get(ctx, fmt.Sprintf(\"/workspaces/%s/project/init-prompt\", id), nil, nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get init prompt: %w\", err)\n\t}\n\tdefer rsp.Body.Close()\n\tif rsp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"failed to get init prompt: status code %d\", rsp.StatusCode)\n\t}\n\tvar result struct {\n\t\tPrompt string `json:\"prompt\"`\n\t}\n\tif err := json.NewDecoder(rsp.Body).Decode(&result); err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to decode init prompt response: %w\", err)\n\t}\n\treturn result.Prompt, nil\n}\n\n// ListSkills retrieves the visible skills for a workspace.\nfunc (c *Client) ListSkills(ctx context.Context, id string) ([]proto.SkillInfo, error) {\n\trsp, err := c.get(ctx, fmt.Sprintf(\"/workspaces/%s/skills\", id), nil, nil)\n\tif err != nil {","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/client/config.go#L186-L222","documentation":"GetInitializePrompt performs GET /workspaces/{id}/project/init-prompt and wraps any transport-level failure with this error. The initialization prompt text could not be fetched because the request itself failed before a response arrived. It propagates to callers like InitializePrompt.","triggerScenarios":"Calling Client.GetInitializePrompt(ctx, id) (directly or via InitializePrompt) when the GET fails at the transport layer: unreachable server, reset connection, TLS error, or context deadline exceeded.","commonSituations":"First-run setup performed while offline; server restarted during onboarding; wrong port or base URL; slow server exceeding a tight client timeout on first use.","solutions":["Confirm the server is reachable and the base URL is correct","Retry — prompt fetch is a read-only, safe-to-repeat request","Increase the client timeout if the first request includes cold-start latency","Use errors.As on the wrapped error to distinguish timeout vs connection refused"],"exampleFix":"// before\nprompt, err := client.GetInitializePrompt(ctx, id)\nif err != nil {\n    return err\n}\n// after\nprompt, err := client.GetInitializePrompt(ctx, id)\nif err != nil {\n    var netErr net.Error\n    if errors.As(err, &netErr) && netErr.Timeout() {\n        prompt, err = client.GetInitializePrompt(ctx, id)\n    }\n    if err != nil {\n        return err\n    }\n}","handlingStrategy":"retry","validationCode":"// Reachability precheck before fetching the init prompt\nu, _ := url.Parse(client.BaseURL())\nconn, err := net.DialTimeout(\"tcp\", u.Host, 3*time.Second)\nif err != nil {\n    return fmt.Errorf(\"server unreachable: %w\", err)\n}\nconn.Close()","typeGuard":"func isTransportError(err error) bool {\n    var netErr net.Error\n    return errors.As(err, &netErr)\n}","tryCatchPattern":"prompt, err := c.GetInitializePrompt(ctx, id)\nif err != nil {\n    var netErr net.Error\n    if errors.As(err, &netErr) && netErr.Timeout() {\n        prompt, err = c.GetInitializePrompt(ctx, id)\n    }\n    if err != nil {\n        return err\n    }\n}","preventionTips":["Retry read-only prompt fetches on transient network errors","Warm up the server before first-use onboarding flows to avoid cold-start timeouts","Cache the last fetched prompt as a fallback when offline","Use bounded but realistic context deadlines for first requests"],"tags":["http-client","network","bootstrap"],"backgroundTag":"http-request-failed","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}