{"record":{"id":"bad1ee8b5489700b","repo":"googleapis/mcp-toolbox","slug":"failed-to-cancel-operation-w","errorCode":null,"errorMessage":"failed to cancel operation: %w","messagePattern":"failed to cancel operation: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/serverlessspark/serverlessspark.go","lineNumber":166,"sourceCode":"func (s *Source) GetOperationsClient(ctx context.Context) (*longrunning.OperationsClient, error) {\n\treturn s.OpsClient, nil\n}\n\nfunc (s *Source) Close() error {\n\treturn errors.Join(s.BatchClient.Close(), s.SessionClient.Close(), s.SessionTemplateClient.Close(), s.OpsClient.Close())\n}\n\nfunc (s *Source) CancelOperation(ctx context.Context, operation string) (any, error) {\n\treq := &longrunningpb.CancelOperationRequest{\n\t\tName: fmt.Sprintf(\"projects/%s/locations/%s/operations/%s\", s.GetProject(), s.GetLocation(), operation),\n\t}\n\tclient, err := s.GetOperationsClient(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get operations client: %w\", err)\n\t}\n\terr = client.CancelOperation(ctx, req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to cancel operation: %w\", err)\n\t}\n\treturn fmt.Sprintf(\"Cancelled [%s].\", operation), nil\n}\n\nfunc (s *Source) CreateBatch(ctx context.Context, batch *dataprocpb.Batch) (map[string]any, error) {\n\treq := &dataprocpb.CreateBatchRequest{\n\t\tParent: fmt.Sprintf(\"projects/%s/locations/%s\", s.GetProject(), s.GetLocation()),\n\t\tBatch:  batch,\n\t}\n\n\tclient := s.GetBatchControllerClient()\n\top, err := client.CreateBatch(ctx, req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create batch: %w\", err)\n\t}\n\tmeta, err := op.Metadata()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get create batch op metadata: %w\", err)","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/serverlessspark/serverlessspark.go#L148-L184","documentation":"The longrunning CancelOperation RPC for the Dataproc operation failed — the operation name may be invalid/already finished, or the API call was rejected due to permissions or connectivity.","triggerScenarios":"Thrown at internal/sources/serverlessspark/serverlessspark.go:166 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the operation ID exists and is still running for the project/location","Check IAM permissions (dataproc operations cancel) and ADC validity","Retry on transient API errors"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}