{"record":{"id":"975787228e81c9bd","repo":"github/github-mcp-server","slug":"failed-to-marshal-workflow-w","errorCode":null,"errorMessage":"failed to marshal workflow: %w","messagePattern":"failed to marshal workflow: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/github/actions.go","lineNumber":793,"sourceCode":"func getWorkflow(ctx context.Context, client *github.Client, owner, repo, resourceID string) (*mcp.CallToolResult, any, error) {\n\tvar workflow *github.Workflow\n\tvar resp *github.Response\n\tvar err error\n\n\tif workflowIDInt, parseErr := strconv.ParseInt(resourceID, 10, 64); parseErr == nil {\n\t\tworkflow, resp, err = client.Actions.GetWorkflowByID(ctx, owner, repo, workflowIDInt)\n\t} else {\n\t\tworkflow, resp, err = client.Actions.GetWorkflowByFileName(ctx, owner, repo, resourceID)\n\t}\n\n\tif err != nil {\n\t\treturn ghErrors.NewGitHubAPIErrorResponse(ctx, \"failed to get workflow\", resp, err), nil, nil\n\t}\n\n\tdefer func() { _ = resp.Body.Close() }()\n\tr, err := json.Marshal(workflow)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to marshal workflow: %w\", err)\n\t}\n\n\treturn utils.NewToolResultText(string(r)), nil, nil\n}\n\nfunc getWorkflowRun(ctx context.Context, client *github.Client, owner, repo string, resourceID int64) (*mcp.CallToolResult, any, error) {\n\tworkflowRun, resp, err := client.Actions.GetWorkflowRunByID(ctx, owner, repo, resourceID)\n\tif err != nil {\n\t\treturn ghErrors.NewGitHubAPIErrorResponse(ctx, \"failed to get workflow run\", resp, err), nil, nil\n\t}\n\tdefer func() { _ = resp.Body.Close() }()\n\tr, err := json.Marshal(convertToMinimalWorkflowRun(workflowRun))\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to marshal workflow run: %w\", err)\n\t}\n\treturn utils.NewToolResultText(string(r)), nil, nil\n}\n","sourceCodeStart":775,"sourceCodeEnd":811,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/actions.go#L775-L811","documentation":"Defensive guard in getWorkflow (pkg/github/actions.go:793): json.Marshal of a *github.Workflow returned by GetWorkflowByID or GetWorkflowByFileName failed. go-github structs are plain JSON-safe data types, so this is effectively unreachable unless the struct contains a non-serializable field (func, chan, NaN, cycle) - which would be a go-github or server regression, not caller input.","triggerScenarios":"Calling get_action_workflow (by numeric ID or by .yml file name) after a go-github upgrade that introduced a JSON-unsafe field; fork modifications embedding non-serializable state in the workflow struct.","commonSituations":"Virtually never in stock deployments; appears in forks or after unusual dependency versions.","solutions":["Report upstream with the exact arguments and versions - input cannot trigger it","Pin go-github and github-mcp-server to known-good versions","If patching, marshal a minimal DTO instead of the raw struct","Add a regression test marshaling the struct shape"],"exampleFix":"// before\nr, err := json.Marshal(workflow)\nif err != nil {\n    return nil, nil, fmt.Errorf(\"failed to marshal workflow: %w\", err)\n}\n\n// after - marshal a stable DTO to decouple from go-github struct churn\nminimal := map[string]any{\n    \"id\": workflow.GetID(), \"name\": workflow.GetName(), \"path\": workflow.GetPath(), \"state\": workflow.GetState(),\n}\nr, err := json.Marshal(minimal)","handlingStrategy":"validation","validationCode":"// Maintainer-side: keep the marshaled payload JSON-safe\nif _, err := json.Marshal(workflow); err != nil {\n    return fmt.Errorf(\"workflow not JSON-safe before tool return: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    // deterministic serialization failure: report, never retry\n    reportIssue(\"get_action_workflow\", args, err, version())\n    return err\n}","preventionTips":["Pin go-github and github-mcp-server versions","Marshal-test API structs in CI after dependency upgrades","Prefer marshaling minimal DTOs over raw library structs","Treat this error as a bug signature, not an operational condition"],"tags":["json","serialization","workflow","go"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}