{"record":{"id":"1135077fd004ae0c","repo":"googleapis/mcp-toolbox","slug":"failed-to-list-jobs-w","errorCode":null,"errorMessage":"failed to list jobs: %w","messagePattern":"failed to list jobs: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/dataproc/dataproc.go","lineNumber":313,"sourceCode":"\tif jobStateMatcher != \"\" {\n\t\tif v, ok := dataprocpb.ListJobsRequest_JobStateMatcher_value[jobStateMatcher]; ok {\n\t\t\treq.JobStateMatcher = dataprocpb.ListJobsRequest_JobStateMatcher(v)\n\t\t} else {\n\t\t\treturn nil, fmt.Errorf(\"invalid jobStateMatcher: %s. Supported values: ALL, ACTIVE, NON_ACTIVE\", jobStateMatcher)\n\t\t}\n\t}\n\n\tit := client.ListJobs(ctx, req)\n\tps := 0\n\tif pageSize != nil {\n\t\tps = *pageSize\n\t}\n\tpager := iterator.NewPager(it, ps, req.PageToken)\n\n\tvar jobPbs []*dataprocpb.Job\n\tnextPageToken, err := pager.NextPage(&jobPbs)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to list jobs: %w\", err)\n\t}\n\n\tjobs, err := ToJobs(jobPbs, s.Region)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn ListJobsResponse{Jobs: jobs, NextPageToken: nextPageToken}, nil\n}\n\n// ToJobs converts a slice of protobuf Job messages to a slice of Job structs.\nfunc ToJobs(jobPbs []*dataprocpb.Job, region string) ([]Job, error) {\n\tjobs := make([]Job, 0, len(jobPbs))\n\tfor _, jobPb := range jobPbs {\n\t\tconsoleUrl := JobConsoleURLFromProto(jobPb, region)\n\t\tlogsUrl, err := JobLogsURLFromProto(jobPb, region)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error generating logs url: %v\", err)","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/dataproc/dataproc.go#L295-L331","documentation":"ListJobs wraps any error returned by the Dataproc pager while iterating a page of jobs (pager.NextPage). This library wraps the underlying Google API error with %w so callers can inspect it with errors.Is/As. It indicates the RPC to the Dataproc API failed while listing jobs in the configured region.","triggerScenarios":"Calling ListJobs when the Dataproc API call fails: invalid/missing region, disabled Dataproc API, insufficient IAM permissions (dataproc.jobs.list), network failure, or an invalid page token.","commonSituations":"Misconfigured region in the source config (e.g. region set to a location with no projects access), service account lacking roles/dataproc.viewer, quota exhaustion, or transient 5xx from the Dataproc API.","solutions":["Unwrap the error (errors.Unwrap / %v formatting) to see the underlying gRPC status and act on it","Verify the region in the Dataproc source config matches where the cluster/jobs live (use 'global' or the correct regional endpoint)","Grant the caller's service account the dataproc.jobs.list permission (roles/dataproc.viewer or roles/dataproc.editor)","Enable the Dataproc API on the project and check quota/limits","Retry on transient errors with backoff"],"exampleFix":"// before\njobs, err := toolbox.ListJobs(ctx, pageSize, token)\n// after\njobs, err := toolbox.ListJobs(ctx, pageSize, token)\nif err != nil {\n\tlog.Printf(\"list jobs failed: %v\", err) // wrapped gRPC error shows real cause\n\tif st, ok := status.FromError(errors.Unwrap(err)); ok && st.Code() == codes.PermissionDenied { ... }\n}","handlingStrategy":"try-catch","validationCode":"if region == \"\" || projectID == \"\" {\n\treturn fmt.Errorf(\"region and projectId must be set before listing Dataproc jobs\")\n}","typeGuard":null,"tryCatchPattern":"jobs, err := svc.ListJobs(ctx, pageSize, token)\nif err != nil {\n\tif u := errors.Unwrap(err); u != nil && strings.Contains(u.Error(), \"PermissionDenied\") {\n\t\t// fix IAM\n\t}\n\treturn fmt.Errorf(\"listing dataproc jobs: %w\", err)\n}","preventionTips":["Set the correct region in the source config before calling","Grant roles/dataproc.viewer to the service account","Enable the Dataproc API on the project","Retry transient failures with exponential backoff"],"tags":["gcp","dataproc","api-error","wrapped-error"],"backgroundTag":"gcp-api-request-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"}