chenhg5/cc-connect · error

googlechat: subscription is required (the Pub/Sub subscripti

Error message

googlechat: subscription is required (the Pub/Sub subscription your Chat app publishes to)

What it means

googlechat.New validates its configuration before constructing the platform. It requires the 'subscription' option: the Cloud Pub/Sub subscription that the Google Chat app publishes events to. An empty or whitespace-only value aborts construction with this message.

Source

Thrown at platform/googlechat/googlechat.go:87

	projectID       string // parsed from subscription, for the Pub/Sub client
	credentialsFile string // service-account key, used for both receive and send
	tokenSource     oauth2.TokenSource
	allowFrom       string
	sessionScope    string // "space" (default) | "thread" | "user"

	botClient *http.Client // service-account authed client for sending
	psClient  *pubsub.Client

	handler core.MessageHandler
	cancel  context.CancelFunc
}

// New builds a Google Chat platform from config options.
func New(opts map[string]any) (core.Platform, error) {
	subscription, _ := opts["subscription"].(string)
	subscription = strings.TrimSpace(subscription)
	if subscription == "" {
		return nil, fmt.Errorf("googlechat: subscription is required (the Pub/Sub subscription your Chat app publishes to)")
	}
	projectID, err := projectFromSubscription(subscription)
	if err != nil {
		return nil, err
	}

	credentialsFile, _ := opts["credentials_file"].(string)
	credentialsFile = strings.TrimSpace(credentialsFile)
	if credentialsFile == "" {
		return nil, fmt.Errorf("googlechat: credentials_file is required (the Chat app's service-account key, used to pull events and send replies)")
	}
	keyBytes, err := os.ReadFile(credentialsFile)
	if err != nil {
		return nil, fmt.Errorf("googlechat: read credentials_file: %w", err)
	}
	conf, err := google.JWTConfigFromJSON(keyBytes,
		chatBotScope, "https://www.googleapis.com/auth/pubsub")
	if err != nil {

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Set subscription in the googlechat platform config to the full Pub/Sub subscription resource name, e.g. "projects/my-project/subscriptions/chat-app-events"
  2. Check the config key spelling is exactly 'subscription'
  3. Verify the value is non-empty after env expansion (echo it or run cc-connect doctor)
  4. See TestNew_MissingSubscription for the exact accepted shape

Example fix

// before
[[platforms]]
type = "googlechat"
# subscription missing
// after
[[platforms]]
type = "googlechat"
[platforms.options]
subscription = "projects/my-project/subscriptions/chat-events"
Defensive patterns

Strategy: validation

Validate before calling

// Go: validate options before calling googlechat.New
sub, _ := opts["subscription"].(string)
if strings.TrimSpace(sub) == "" {
    return errors.New("googlechat: subscription must be a non-empty Pub/Sub subscription resource name")
}

Try / catch

p, err := core.CreatePlatform("googlechat", opts)
if err != nil && strings.Contains(err.Error(), "subscription is required") {
    return fmt.Errorf("config: set [platforms.options] subscription = \"projects/<proj>/subscriptions/<name>\": %w", err)
}

Prevention

When it happens

Trigger: Calling core.CreatePlatform("googlechat", opts) (or googlechat.New directly) where opts["subscription"] is absent, not a string, an empty string, or only whitespace.

Common situations: Missing the [platforms.googlechat] subscription entry in config.toml; key typo ('subscriptions', 'pubsub_subscription'); env-var substitution left the value empty; copying a config template without filling in the subscription resource name.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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