{"record":{"id":"64f0dc751c7764f9","repo":"github/github-mcp-server","slug":"failed-to-marshal-workflow-job-w","errorCode":null,"errorMessage":"failed to marshal workflow job: %w","messagePattern":"failed to marshal workflow job: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/github/actions.go","lineNumber":820,"sourceCode":"\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\nfunc getWorkflowJob(ctx context.Context, client *github.Client, owner, repo string, resourceID int64) (*mcp.CallToolResult, any, error) {\n\tworkflowJob, resp, err := client.Actions.GetWorkflowJobByID(ctx, owner, repo, resourceID)\n\tif err != nil {\n\t\treturn ghErrors.NewGitHubAPIErrorResponse(ctx, \"failed to get workflow job\", resp, err), nil, nil\n\t}\n\tdefer func() { _ = resp.Body.Close() }()\n\tr, err := json.Marshal(workflowJob)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to marshal workflow job: %w\", err)\n\t}\n\treturn utils.NewToolResultText(string(r)), nil, nil\n}\n\nfunc listWorkflows(ctx context.Context, client *github.Client, owner, repo string, pagination PaginationParams) (*mcp.CallToolResult, any, error) {\n\topts := &github.ListOptions{\n\t\tPerPage: pagination.PerPage,\n\t\tPage:    pagination.Page,\n\t}\n\n\tworkflows, resp, err := client.Actions.ListWorkflows(ctx, owner, repo, opts)\n\tif err != nil {\n\t\treturn ghErrors.NewGitHubAPIErrorResponse(ctx, \"failed to list workflows\", resp, err), nil, nil\n\t}\n\tdefer func() { _ = resp.Body.Close() }()\n\n\tr, err := json.Marshal(workflows)\n\tif err != nil {","sourceCodeStart":802,"sourceCodeEnd":838,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/actions.go#L802-L838","documentation":"Defensive guard in getWorkflowJob (pkg/github/actions.go:820): json.Marshal of the *github.WorkflowJob returned by GetWorkflowJobByID failed. The go-github WorkflowJob struct is composed of JSON-safe data types, so this branch is effectively unreachable barring a regression that introduces func/chan/NaN/cyclic values.","triggerScenarios":"Calling get_action_workflow_job with a valid job ID after a dependency upgrade introduces serialization-unsafe fields; fork code attaching channels or funcs to the job struct.","commonSituations":"Not seen with stock releases; theoretical risk during go-github major upgrades.","solutions":["Report upstream with arguments and dependency versions","Pin go-github to a version where the tool worked","If patching, marshal an explicit subset of fields","Add marshal coverage to CI"],"exampleFix":"// before\nr, err := json.Marshal(workflowJob)\nif err != nil {\n    return nil, nil, fmt.Errorf(\"failed to marshal workflow job: %w\", err)\n}\n\n// after - subset DTO decouples the wire format from the go-github struct\nr, err := json.Marshal(map[string]any{\n    \"id\": workflowJob.GetID(), \"name\": workflowJob.GetName(), \"status\": workflowJob.GetStatus(), \"conclusion\": workflowJob.GetConclusion(),\n})","handlingStrategy":"validation","validationCode":"// Test-side guard: ensure the job struct round-trips\nfunc TestWorkflowJobMarshal(t *testing.T) {\n    if _, err := json.Marshal(&github.WorkflowJob{}); err != nil {\n        t.Fatalf(\"workflow job not JSON-safe: %v\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    reportIssue(\"get_action_workflow_job\", map[string]any{\"job_id\": id}, err, version())\n    return err\n}","preventionTips":["Pin known-good dependency versions","Marshal-test go-github structs after major upgrades","Use DTO subsetting for stable wire formats","Report rather than retry"],"tags":["json","serialization","workflow-job","go"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}