charmbracelet/crush · error
failed to get init prompt: %w
Error message
failed to get init prompt: %w
What it means
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.
Source
Thrown at internal/client/config.go:204
// server.
func (c *Client) MarkProjectInitialized(ctx context.Context, id string) error {
rsp, err := c.post(ctx, fmt.Sprintf("/workspaces/%s/project/init", id), nil, nil, nil)
if err != nil {
return fmt.Errorf("failed to mark project initialized: %w", err)
}
defer rsp.Body.Close()
if rsp.StatusCode != http.StatusOK {
return fmt.Errorf("failed to mark project initialized: status code %d", rsp.StatusCode)
}
return nil
}
// GetInitializePrompt retrieves the initialization prompt from the
// server.
func (c *Client) GetInitializePrompt(ctx context.Context, id string) (string, error) {
rsp, err := c.get(ctx, fmt.Sprintf("/workspaces/%s/project/init-prompt", id), nil, nil)
if err != nil {
return "", fmt.Errorf("failed to get init prompt: %w", err)
}
defer rsp.Body.Close()
if rsp.StatusCode != http.StatusOK {
return "", fmt.Errorf("failed to get init prompt: status code %d", rsp.StatusCode)
}
var result struct {
Prompt string `json:"prompt"`
}
if err := json.NewDecoder(rsp.Body).Decode(&result); err != nil {
return "", fmt.Errorf("failed to decode init prompt response: %w", err)
}
return result.Prompt, nil
}
// ListSkills retrieves the visible skills for a workspace.
func (c *Client) ListSkills(ctx context.Context, id string) ([]proto.SkillInfo, error) {
rsp, err := c.get(ctx, fmt.Sprintf("/workspaces/%s/skills", id), nil, nil)
if err != nil {View on GitHub (pinned to 7944b8e522)
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
Example fix
// before
prompt, err := client.GetInitializePrompt(ctx, id)
if err != nil {
return err
}
// after
prompt, err := client.GetInitializePrompt(ctx, id)
if err != nil {
var netErr net.Error
if errors.As(err, &netErr) && netErr.Timeout() {
prompt, err = client.GetInitializePrompt(ctx, id)
}
if err != nil {
return err
}
} Defensive patterns
Strategy: retry
Validate before calling
// Reachability precheck before fetching the init prompt
u, _ := url.Parse(client.BaseURL())
conn, err := net.DialTimeout("tcp", u.Host, 3*time.Second)
if err != nil {
return fmt.Errorf("server unreachable: %w", err)
}
conn.Close() Type guard
func isTransportError(err error) bool {
var netErr net.Error
return errors.As(err, &netErr)
} Try / catch
prompt, err := c.GetInitializePrompt(ctx, id)
if err != nil {
var netErr net.Error
if errors.As(err, &netErr) && netErr.Timeout() {
prompt, err = c.GetInitializePrompt(ctx, id)
}
if err != nil {
return err
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
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
- failed to check project init: %w
- failed to mark project initialized: %w
- failed to make request: %w
- failed to refresh OAuth token: %w
- failed to check project init: status code %d
AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29).
Data as JSON: /api/errors/a9978c3cffe63cd5.
Report an issue: GitHub.