chenhg5/cc-connect · error

googlechat: subscription must be of the form projects/<proje

Error message

googlechat: subscription must be of the form projects/<project>/subscriptions/<name>, got %q

What it means

projectFromSubscription parses the configured Pub/Sub subscription resource name and extracts the GCP project ID so the Pub/Sub client can target the right project. The error is thrown when the subscription string does not match the canonical form projects/<project>/subscriptions/<name>, which means the googlechat platform cannot determine which project to create the Pub/Sub client against. It is a startup-time configuration validation error surfaced from New().

Source

Thrown at platform/googlechat/googlechat.go:132

	return &Platform{
		subscription:    subscription,
		projectID:       projectID,
		credentialsFile: credentialsFile,
		tokenSource:     conf.TokenSource(context.Background()),
		allowFrom:       allowFrom,
		sessionScope:    normalizeSessionScope(opts["session_scope"]),
		botClient:       botClient,
	}, nil
}

// projectFromSubscription extracts the project ID from a Pub/Sub subscription
// resource name so the Pub/Sub client can be created for the right project.
func projectFromSubscription(sub string) (string, error) {
	parts := strings.Split(sub, "/")
	if len(parts) == 4 && parts[0] == "projects" && parts[2] == "subscriptions" {
		return parts[1], nil
	}
	return "", fmt.Errorf("googlechat: subscription must be of the form projects/<project>/subscriptions/<name>, got %q", sub)
}

// normalizeSessionScope resolves session_scope to "space" | "thread" | "user",
// defaulting to "space".
func normalizeSessionScope(raw any) string {
	s, _ := raw.(string)
	switch strings.ToLower(strings.TrimSpace(s)) {
	case "thread":
		return "thread"
	case "user":
		return "user"
	case "space", "":
		return "space"
	default:
		slog.Warn("googlechat: unknown session_scope, using \"space\"", "value", s)
		return "space"
	}
}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Set subscription in the googlechat platform config to the exact resource name: projects/my-project/subscriptions/my-sub
  2. Run `gcloud pubsub subscriptions describe <name> --format='value(name)'` and copy the returned full name into the config
  3. Verify there are no surrounding quotes/whitespace and the path has exactly 4 slash-separated segments with 'projects' first and 'subscriptions' third

Example fix

// before
subscription = "my-chat-sub"

// after
subscription = "projects/my-gcp-project/subscriptions/my-chat-sub"
Defensive patterns

Strategy: validation

Validate before calling

ok := func(sub string) bool { p := strings.Split(sub, "/"); return len(p) == 4 && p[0] == "projects" && p[2] == "subscriptions" }(cfg.Subscription)
if !ok { return fmt.Errorf("config: bad googlechat subscription %q", cfg.Subscription) }

Prevention

When it happens

Trigger: Setting the googlechat subscription config value to anything other than projects/<project>/subscriptions/<name>: a bare subscription name, a full URL like https://pubsub.googleapis.com/..., a resource path with extra segments, or an empty string.

Common situations: Copying the subscription's numeric ID instead of its resource name; pasting the subscription's web-console URL; truncating the string when hand-editing config.toml; confusing the topic path (projects/<p>/topics/<t>) with the subscription path.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/80128645f5dd1661. Report an issue: GitHub.