{"record":{"id":"dfac7b882f7f794a","repo":"gastownhall/beads","slug":"failed-to-parse-work-item-types-response-w","errorCode":null,"errorMessage":"failed to parse work item types response: %w","messagePattern":"failed to parse work item types response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/ado/client.go","lineNumber":597,"sourceCode":"\n\tvar projects []Project\n\tif err := json.Unmarshal(envelope.Value, &projects); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse projects value: %w\", err)\n\t}\n\treturn projects, nil\n}\n\n// GetWorkItemTypes returns the work item types available in the project.\nfunc (c *Client) GetWorkItemTypes(ctx context.Context) ([]WorkItemType, error) {\n\turlStr := addAPIVersion(c.apiBase() + \"/wit/workitemtypes\")\n\trespBody, err := c.doRequest(ctx, http.MethodGet, urlStr, \"\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get work item types: %w\", err)\n\t}\n\n\tvar envelope listResponse\n\tif err := json.Unmarshal(respBody, &envelope); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse work item types response: %w\", err)\n\t}\n\n\tvar types []WorkItemType\n\tif err := json.Unmarshal(envelope.Value, &types); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse work item types value: %w\", err)\n\t}\n\treturn types, nil\n}\n\n// GetWorkItemStates returns the states for a given work item type.\nfunc (c *Client) GetWorkItemStates(ctx context.Context, typeName string) ([]WorkItemState, error) {\n\turlStr := addAPIVersion(c.apiBase() + \"/wit/workitemtypes/\" + url.PathEscape(typeName) + \"/states\")\n\trespBody, err := c.doRequest(ctx, http.MethodGet, urlStr, \"\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get work item states: %w\", err)\n\t}\n\n\tvar envelope listResponse","sourceCodeStart":579,"sourceCodeEnd":615,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/ado/client.go#L579-L615","documentation":"This error means GetWorkItemTypes received a response but json.Unmarshal of the raw body into the generic listResponse envelope failed. The body was not the expected {\"value\": [...]} JSON — commonly an HTML page, empty body, or malformed JSON.","triggerScenarios":"Calling GetWorkItemTypes when the endpoint returns non-JSON: HTML login/proxy page with 200, empty response, truncated body, or an ADO error page.","commonSituations":"Auth proxy intercepting requests; hitting the web UI URL instead of the API; transient network truncation; ADO service degradation returning HTML.","solutions":["Capture and inspect the raw response body to identify what was returned instead of JSON","Verify the request is going to the API endpoint, not behind an HTML auth wall or proxy","Retry transient failures; truncated bodies commonly follow network blips","Confirm the client's project/org URL configuration is an API base"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"types, err := client.GetWorkItemTypes(ctx)\nif err != nil {\n  if strings.Contains(err.Error(), \"failed to parse work item types response\") {\n    return nil, fmt.Errorf(\"non-JSON response from workitemtypes endpoint (proxy/auth page?): %w\", err)\n  }\n  return nil, err\n}","preventionTips":["Verify the API host is not behind an HTML auth wall","Curl the endpoint to confirm JSON body before integrating","Retry truncated responses; they follow network blips","Monitor ADO status during service incidents"],"tags":["json","parsing","azure-devops","response-shape"],"backgroundTag":"json-decode-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}