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
nameView on GitHub (pinned to 71377f2769)
Solutions
- Dump the raw `data` bytes to inspect the actual response.
- Check for a top-level "errors" array — the mutation likely failed and the error message is there.
- Compare ProjectCreateResponse and nested Project fields against the current Linear GraphQL schema; fix field names/types.
- Test the same mutation manually (curl/Altair) to confirm the expected shape.
- 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
- Check for a GraphQL "errors" key before unmarshalling into the typed response.
- Keep ProjectCreateResponse fields minimal and matching the mutation's selection set exactly.
- Add an integration test that creates (and cleans up) a project to catch drift.
- Log raw response bodies when decode errors occur.
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
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to parse teams response: %w
- failed to parse projects response: %w
- failed to create project: %w
- project creation reported as unsuccessful
- parsing waits-for metadata to set also_blocks: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/debbee363fc2972c.
Report an issue: GitHub.