{"record":{"id":"88b244b1a0d40fa1","repo":"charmbracelet/crush","slug":"failed-to-mark-project-initialized-w","errorCode":null,"errorMessage":"failed to mark project initialized: %w","messagePattern":"failed to mark project initialized: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/client/config.go","lineNumber":190,"sourceCode":"\tdefer rsp.Body.Close()\n\tif rsp.StatusCode != http.StatusOK {\n\t\treturn false, fmt.Errorf(\"failed to check project init: status code %d\", rsp.StatusCode)\n\t}\n\tvar result struct {\n\t\tNeedsInit bool `json:\"needs_init\"`\n\t}\n\tif err := json.NewDecoder(rsp.Body).Decode(&result); err != nil {\n\t\treturn false, fmt.Errorf(\"failed to decode project init response: %w\", err)\n\t}\n\treturn result.NeedsInit, nil\n}\n\n// MarkProjectInitialized marks the project as initialized on the\n// 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)","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/client/config.go#L172-L208","documentation":"MarkProjectInitialized POSTs to /workspaces/{id}/project/init and wraps transport-level request failures with this error. The initialization flag could not be set because the request never completed.","triggerScenarios":"Calling Client.MarkProjectInitialized(ctx, id) when the POST fails at the transport layer: server unreachable, connection reset, TLS handshake failure, or the context was cancelled first.","commonSituations":"Server shut down between the needs-init check and the mark call; laptop sleeping mid-initialization; misconfigured base URL; VPN dropping during project setup.","solutions":["Verify server availability and re-run MarkProjectInitialized — marking init is safe to retry","Check ctx deadlines if initialization steps are slow","Validate the client's base URL and proxy settings","Inspect the wrapped error to distinguish timeout vs connection refused"],"exampleFix":"// before\nif err := client.MarkProjectInitialized(ctx, id); err != nil {\n    return err\n}\n// after\nif err := client.MarkProjectInitialized(ctx, id); err != nil {\n    if ctx.Err() != nil {\n        return fmt.Errorf(\"init mark cancelled: %w\", ctx.Err())\n    }\n    return err\n}","handlingStrategy":"retry","validationCode":"// Confirm reachability and that the project still needs init before marking\nif err := ctx.Err(); err != nil {\n    return err\n}\nneedsInit, err := client.ProjectNeedsInitialization(ctx, id)\nif err != nil {\n    return err\n}\nif !needsInit {\n    return nil\n}","typeGuard":"func isTransportError(err error) bool {\n    var netErr net.Error\n    return errors.As(err, &netErr)\n}","tryCatchPattern":"if err := c.MarkProjectInitialized(ctx, id); err != nil {\n    var netErr net.Error\n    if errors.As(err, &netErr) {\n        return retryWithBackoff(ctx, func() error { return c.MarkProjectInitialized(ctx, id) })\n    }\n    return err\n}","preventionTips":["Marking init is idempotent — retry transport failures safely","Keep the needs-init check and mark call close together with a shared context","Avoid long-running work between check and mark that could let connections die","Set explicit context timeouts instead of relying on defaults"],"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"}