{"record":{"id":"2304f9b46a097e31","repo":"github/github-mcp-server","slug":"failed-to-marshal-workflow-run-w","errorCode":null,"errorMessage":"failed to marshal workflow run: %w","messagePattern":"failed to marshal workflow run: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/github/actions.go","lineNumber":807,"sourceCode":"\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\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) {","sourceCodeStart":789,"sourceCodeEnd":825,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/actions.go#L789-L825","documentation":"Defensive guard in getWorkflowRun (pkg/github/actions.go:807): json.Marshal of convertToMinimalWorkflowRun(workflowRun) failed. The conversion produces a server-owned minimal struct of scalar fields, so this is effectively unreachable unless a regression adds a non-serializable value (func, chan, NaN, cycle) to that struct.","triggerScenarios":"Calling get_action_workflow_run with a valid run ID after code changes made convertToMinimalWorkflowRun emit JSON-unsafe values; NaN timestamps/durations introduced by timezone or duration math bugs.","commonSituations":"Not seen in stock releases; a hazard only for forks that extend the minimal-run struct.","solutions":["Report upstream if hit with a stock release - include run ID and versions","Keep the minimal struct scalar-only (string, int, bool, time as string)","Unit-test the conversion plus marshal path","Pin known-good versions"],"exampleFix":"// before\nr, err := json.Marshal(convertToMinimalWorkflowRun(workflowRun))\nif err != nil {\n    return nil, nil, fmt.Errorf(\"failed to marshal workflow run: %w\", err)\n}\n\n// after - guard the conversion itself with a test-friendly error\nminimal := convertToMinimalWorkflowRun(workflowRun)\nr, err := json.Marshal(minimal)\nif err != nil {\n    return nil, nil, fmt.Errorf(\"failed to marshal workflow run (run %d): %w\", workflowRun.GetID(), err)\n}","handlingStrategy":"validation","validationCode":"// Validate the converted struct is JSON-safe in tests\nfunc TestMinimalWorkflowRunMarshal(t *testing.T) {\n    if _, err := json.Marshal(convertToMinimalWorkflowRun(&github.WorkflowRun{})); err != nil {\n        t.Fatalf(\"minimal run not JSON-safe: %v\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    reportIssue(\"get_action_workflow_run\", map[string]any{\"run_id\": runID}, err, version())\n    return err\n}","preventionTips":["Keep converted structs scalar-only","Format times as strings in DTOs","Pin versions; watch changelogs for serialization fixes","Do not retry deterministic marshal failures"],"tags":["json","serialization","workflow-run","go"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}