googleapis/mcp-toolbox · error

error extracting batch details from name %q: %v

Error message

error extracting batch details from name %q: %v

What it means

ExtractBatchDetails could not regex-match the batch name returned in the operation metadata against the expected projects/<project>/locations/<location>/batches/<batch_id> shape, so the created batch cannot be decomposed into project, location and batch ID.

Source

Thrown at internal/sources/serverlessspark/serverlessspark.go:189

func (s *Source) CreateBatch(ctx context.Context, batch *dataprocpb.Batch) (map[string]any, error) {
	req := &dataprocpb.CreateBatchRequest{
		Parent: fmt.Sprintf("projects/%s/locations/%s", s.GetProject(), s.GetLocation()),
		Batch:  batch,
	}

	client := s.GetBatchControllerClient()
	op, err := client.CreateBatch(ctx, req)
	if err != nil {
		return nil, fmt.Errorf("failed to create batch: %w", err)
	}
	meta, err := op.Metadata()
	if err != nil {
		return nil, fmt.Errorf("failed to get create batch op metadata: %w", err)
	}

	projectID, location, batchID, err := ExtractBatchDetails(meta.GetBatch())
	if err != nil {
		return nil, fmt.Errorf("error extracting batch details from name %q: %v", meta.GetBatch(), err)
	}
	consoleUrl := BatchConsoleURL(projectID, location, batchID)
	logsUrl := BatchLogsURL(projectID, location, batchID, meta.GetCreateTime().AsTime(), time.Time{})

	wrappedResult := map[string]any{
		"opMetadata": meta,
		"consoleUrl": consoleUrl,
		"logsUrl":    logsUrl,
	}
	return wrappedResult, nil
}

// ListBatchesResponse is the response from the list batches API.
type ListBatchesResponse struct {
	Batches       []Batch `json:"batches"`
	NextPageToken string  `json:"nextPageToken"`
}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Inspect the returned batch name in the error to see the malformed shape
  2. Verify the Dataproc API version returns fully qualified batch names
  3. Report if the resource-name format changed upstream
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/sources/serverlessspark/serverlessspark.go:189 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/e41498d31857edf2. Report an issue: GitHub.