googleapis/mcp-toolbox · error

failed to parse session name: %s

Error message

failed to parse session name: %s

What it means

The session name regex failed to match the given session name: it does not follow projects/<project>/locations/<location>/sessions/<session_id>, so its components cannot be extracted for console/log URL construction.

Source

Thrown at internal/sources/serverlessspark/url.go:109

	return BatchLogsURL(projectID, location, batchID, createTime, stateTime), nil
}

// ExtractSessionTemplateDetails extracts the project ID, location, and session template ID from a fully qualified sessionTemplateName.
func ExtractSessionTemplateDetails(sessionTemplateName string) (projectID, location, sessionTemplateID string, err error) {
	matches := sessionTemplateFullNameRegex.FindStringSubmatch(sessionTemplateName)
	if len(matches) < 4 {
		return "", "", "", fmt.Errorf("failed to parse session template name: %s", sessionTemplateName)
	}
	return matches[1], matches[2], matches[3], nil
}

var sessionFullNameRegex = regexp.MustCompile(`projects/(?P<project>[^/]+)/locations/(?P<location>[^/]+)/sessions/(?P<session_id>[^/]+)`)

// ExtractSessionDetails extracts the project ID, location, and session ID from a fully qualified session name.
func ExtractSessionDetails(sessionName string) (projectID, location, sessionID string, err error) {
	matches := sessionFullNameRegex.FindStringSubmatch(sessionName)
	if len(matches) < 4 {
		return "", "", "", fmt.Errorf("failed to parse session name: %s", sessionName)
	}
	return matches[1], matches[2], matches[3], nil
}

// SessionConsoleURL builds a URL to the Google Cloud Console linking to the session summary page.
func SessionConsoleURL(projectID, location, sessionID string) string {
	return fmt.Sprintf("https://console.cloud.google.com/dataproc/interactive/%s/%s/details?project=%s", location, sessionID, projectID)
}

// SessionLogsURL builds a URL to the Google Cloud Console showing Cloud Logging for the given session and time range.
func SessionLogsURL(projectID, location, sessionID string, startTime, endTime time.Time) string {
	advancedFilterTemplate := `resource.type="cloud_dataproc_session"
resource.labels.session_id=%q
resource.labels.project_id=%q
resource.labels.location=%q`

	advancedFilter := fmt.Sprintf(advancedFilterTemplate, sessionID, projectID, location)

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Pass a fully qualified session name of the form projects/P/locations/L/sessions/S
  2. Check for typos or extra path segments
  3. Verify the value came from the Dataproc API unmodified
Defensive patterns

Strategy: validation

When it happens

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

Common situations: See trigger scenarios.

Understand the failure class


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