charmbracelet/crush · error
failed to get init prompt: status code %d
Error message
failed to get init prompt: status code %d
What it means
GetInitializePrompt requires HTTP 200 from GET /workspaces/{id}/project/init-prompt; any other status produces this error. The server was reached but refused to return the initialization prompt, so callers like InitializePrompt receive a wrapped failure.
Source
Thrown at internal/client/config.go:208
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 {
return nil, fmt.Errorf("failed to list skills: %w", err)
}
defer rsp.Body.Close()
if rsp.StatusCode != http.StatusOK {View on GitHub (pinned to 7944b8e522)
Solutions
- Read the status code: 401/403 → re-authenticate, 404 → verify the workspace id exists
- Ensure the workspace was created and initialized server-side before fetching its prompt
- Check server deployment/assets if 5xx persists
- Refresh client credentials if auth recently expired
Example fix
// before
prompt, err := client.GetInitializePrompt(ctx, id)
if err != nil {
return err
}
// after
prompt, err := client.GetInitializePrompt(ctx, id)
if err != nil {
if strings.Contains(err.Error(), "status code 404") {
return fmt.Errorf("workspace %s not found: %w", id, err)
}
return err
} Defensive patterns
Strategy: try-catch
Validate before calling
// Confirm the workspace exists before requesting its init prompt
ws, err := client.GetWorkspace(ctx, id)
if err != nil {
return err
}
if ws == nil {
return fmt.Errorf("workspace %s not found", id)
} Type guard
func isStatusError(err error, code int) bool {
return err != nil && strings.Contains(err.Error(), fmt.Sprintf("status code %d", code))
} Try / catch
prompt, err := c.GetInitializePrompt(ctx, id)
if err != nil {
if isStatusError(err, 401) || isStatusError(err, 403) {
return reauthenticate(ctx)
}
if isStatusError(err, 404) {
return ErrWorkspaceNotFound
}
return err
} Prevention
- Create/initialize the workspace before fetching its prompt
- Refresh credentials before onboarding flows to prevent 401/403
- Map status codes to distinct sentinel errors for clean handling
- Retry only 429/5xx statuses, never 4xx
When it happens
Trigger: Calling GetInitializePrompt (or InitializePrompt) and the server responds non-200: 401/403 for unauthorized workspace access, 404 for a non-existent workspace, or 5xx when the server cannot load its prompt template.
Common situations: Querying a workspace before it was fully created; expired auth session during onboarding; server misconfigured without its prompt assets; multi-tenant deployments where the user lacks access to the given workspace id.
Related errors
- failed to check project init: status code %d
- failed to refresh OAuth token: status code %d
- failed to check project init: %w
- failed to mark project initialized: %w
- failed to mark project initialized: status code %d
AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29).
Data as JSON: /api/errors/2994522d00ee36eb.
Report an issue: GitHub.