{"record":{"id":"d0c64cc48b2e12e0","repo":"googleapis/mcp-toolbox","slug":"failed-to-marshal-job-to-json-w","errorCode":null,"errorMessage":"failed to marshal job to JSON: %w","messagePattern":"failed to marshal job to JSON: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/dataproc/dataproc.go","lineNumber":405,"sourceCode":"\n// GetJob gets a single job.\nfunc (s *Source) GetJob(ctx context.Context, jobId string) (any, error) {\n\tclient := s.GetJobControllerClient()\n\n\treq := &dataprocpb.GetJobRequest{\n\t\tProjectId: s.Project,\n\t\tRegion:    s.Region,\n\t\tJobId:     jobId,\n\t}\n\n\tjobPb, err := client.GetJob(ctx, req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get job: %w\", err)\n\t}\n\n\tjsonBytes, err := protojson.Marshal(jobPb)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to marshal job to JSON: %w\", err)\n\t}\n\n\tvar result map[string]any\n\tif err := json.Unmarshal(jsonBytes, &result); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to unmarshal job JSON: %w\", err)\n\t}\n\n\tconsoleUrl := JobConsoleURLFromProto(jobPb, s.Region)\n\tlogsUrl, err := JobLogsURLFromProto(jobPb, s.Region)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error generating logs url: %v\", err)\n\t}\n\n\twrappedResult := map[string]any{\n\t\t\"consoleUrl\": consoleUrl,\n\t\t\"logsUrl\":    logsUrl,\n\t\t\"job\":        result,\n\t}","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/dataproc/dataproc.go#L387-L423","documentation":"After fetching the job proto, GetJob serializes it to JSON with protojson.Marshal. This error means protojson failed to marshal the *dataprocpb.Job. This is rare and usually indicates an invalid or corrupt proto message (e.g. a proto with invalid field state produced by custom middleware or an incompatible library version).","triggerScenarios":"protojson.Marshal returning an error on the fetched Job proto — practically only when the proto is in an invalid state (e.g. invalid oneof contents or incompatible google.golang.org/protobuf versions).","commonSituations":"Version skew between google.golang.org/protobuf and generated pb code; patched/instrumented protos; extremely rare in normal use.","solutions":["Check go.mod for mismatched google.golang.org/protobuf versions and run go mod tidy","Regenerate vendored dataprocpb code if protos were customized","Log the error and retry GetJob; the failure is usually not deterministic in application logic"],"exampleFix":"// before\nrequire google.golang.org/protobuf v1.30.0\n// after\nrequire google.golang.org/protobuf v1.33.0 // align with generated code, then: go mod tidy","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"job, err := svc.GetJob(ctx, jobId)\nif err != nil && strings.Contains(err.Error(), \"marshal job to JSON\") {\n\t// retry once; if persistent, align protobuf library versions\n}","preventionTips":["Keep google.golang.org/protobuf version aligned with generated pb code","Run go mod tidy after dependency upgrades","Avoid patching generated proto types"],"tags":["gcp","dataproc","serialization","protobuf"],"backgroundTag":"json-marshal-failed","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}