gastownhall/beads · error

failed to parse create project response: %w

Error message

failed to parse create project response: %w

What it means

After the projectCreate mutation executes successfully, CreateProject unmarshals the response into ProjectCreateResponse. This error wraps json.Unmarshal failure — the body doesn't match {projectCreate:{success,project:{...}}}. It separates decode failures from request failures and from the explicit success=false case.

Source

Thrown at internal/linear/client.go:1539

	if state != "" {
		input["state"] = state
	}

	req := &GraphQLRequest{
		Query: query,
		Variables: map[string]interface{}{
			"input": input,
		},
	}

	data, err := c.Execute(ctx, req)
	if err != nil {
		return nil, fmt.Errorf("failed to create project: %w", err)
	}

	var createResp ProjectCreateResponse
	if err := json.Unmarshal(data, &createResp); err != nil {
		return nil, fmt.Errorf("failed to parse create project response: %w", err)
	}

	if !createResp.ProjectCreate.Success {
		return nil, fmt.Errorf("project creation reported as unsuccessful")
	}

	return &createResp.ProjectCreate.Project, nil
}

// UpdateProject updates an existing project in Linear.
func (c *Client) UpdateProject(ctx context.Context, projectID string, updates map[string]interface{}) (*Project, error) {
	query := `
		mutation UpdateProject($id: String!, $input: ProjectUpdateInput!) {
			projectUpdate(id: $id, input: $input) {
				success
				project {
					id
					name

View on GitHub (pinned to 71377f2769)

Solutions

  1. Dump the raw `data` bytes to inspect the actual response.
  2. Check for a top-level "errors" array — the mutation likely failed and the error message is there.
  3. Compare ProjectCreateResponse and nested Project fields against the current Linear GraphQL schema; fix field names/types.
  4. Test the same mutation manually (curl/Altair) to confirm the expected shape.
  5. Update the client code or library version to match the current API schema.

Example fix

// before
var createResp ProjectCreateResponse
if err := json.Unmarshal(data, &createResp); err != nil { return nil, err }
// after
var probe struct{ Errors []struct{ Message string `json:"message"` } `json:"errors"` }
if json.Unmarshal(data, &probe) == nil && len(probe.Errors) > 0 {
    return nil, fmt.Errorf("projectCreate failed: %s", probe.Errors[0].Message)
}
var createResp ProjectCreateResponse
if err := json.Unmarshal(data, &createResp); err != nil { return nil, err }
Defensive patterns

Strategy: type-guard

Type guard

func isProjectCreateResponse(data []byte) bool {
    var probe struct {
        ProjectCreate *struct {
            Success bool              `json:"success"`
            Project json.RawMessage   `json:"project"`
        } `json:"projectCreate"`
    }
    return json.Unmarshal(data, &probe) == nil && probe.ProjectCreate != nil
}

Try / catch

project, err := client.CreateProject(ctx, name, desc, state)
if err != nil {
    var ute *json.UnmarshalTypeError
    if errors.As(err, &ute) {
        return fmt.Errorf("projectCreate payload mismatch at %s — verify Linear schema", ute.Field)
    }
    return err
}

Prevention

When it happens

Trigger: c.Execute returned HTTP-200 data not matching ProjectCreateResponse: GraphQL errors envelope instead of data (mutation rejected but surfaced as errors payload), gateway error JSON, or the ProjectCreateResponse/Project structs drifted from the Linear schema (missing project field, wrong types).

Common situations: Struct definition out of date after a Linear API change; proxy returning a JSON error body; response where projectCreate exists but project is null with different shape than the struct expects.

Understand the failure class

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/debbee363fc2972c. Report an issue: GitHub.