{"record":{"id":"80128645f5dd1661","repo":"chenhg5/cc-connect","slug":"googlechat-subscription-must-be-of-the-form-proje","errorCode":null,"errorMessage":"googlechat: subscription must be of the form projects/<project>/subscriptions/<name>, got %q","messagePattern":"googlechat: subscription must be of the form projects/<project>/subscriptions/<name>, got %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/googlechat/googlechat.go","lineNumber":132,"sourceCode":"\treturn &Platform{\n\t\tsubscription:    subscription,\n\t\tprojectID:       projectID,\n\t\tcredentialsFile: credentialsFile,\n\t\ttokenSource:     conf.TokenSource(context.Background()),\n\t\tallowFrom:       allowFrom,\n\t\tsessionScope:    normalizeSessionScope(opts[\"session_scope\"]),\n\t\tbotClient:       botClient,\n\t}, nil\n}\n\n// projectFromSubscription extracts the project ID from a Pub/Sub subscription\n// resource name so the Pub/Sub client can be created for the right project.\nfunc projectFromSubscription(sub string) (string, error) {\n\tparts := strings.Split(sub, \"/\")\n\tif len(parts) == 4 && parts[0] == \"projects\" && parts[2] == \"subscriptions\" {\n\t\treturn parts[1], nil\n\t}\n\treturn \"\", fmt.Errorf(\"googlechat: subscription must be of the form projects/<project>/subscriptions/<name>, got %q\", sub)\n}\n\n// normalizeSessionScope resolves session_scope to \"space\" | \"thread\" | \"user\",\n// defaulting to \"space\".\nfunc normalizeSessionScope(raw any) string {\n\ts, _ := raw.(string)\n\tswitch strings.ToLower(strings.TrimSpace(s)) {\n\tcase \"thread\":\n\t\treturn \"thread\"\n\tcase \"user\":\n\t\treturn \"user\"\n\tcase \"space\", \"\":\n\t\treturn \"space\"\n\tdefault:\n\t\tslog.Warn(\"googlechat: unknown session_scope, using \\\"space\\\"\", \"value\", s)\n\t\treturn \"space\"\n\t}\n}","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/googlechat/googlechat.go#L114-L150","documentation":"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().","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set subscription in the googlechat platform config to the exact resource name: projects/my-project/subscriptions/my-sub","Run `gcloud pubsub subscriptions describe <name> --format='value(name)'` and copy the returned full name into the config","Verify there are no surrounding quotes/whitespace and the path has exactly 4 slash-separated segments with 'projects' first and 'subscriptions' third"],"exampleFix":"// before\nsubscription = \"my-chat-sub\"\n\n// after\nsubscription = \"projects/my-gcp-project/subscriptions/my-chat-sub\"","handlingStrategy":"validation","validationCode":"ok := func(sub string) bool { p := strings.Split(sub, \"/\"); return len(p) == 4 && p[0] == \"projects\" && p[2] == \"subscriptions\" }(cfg.Subscription)\nif !ok { return fmt.Errorf(\"config: bad googlechat subscription %q\", cfg.Subscription) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Copy the full resource name from `gcloud pubsub subscriptions describe --format='value(name)'`, never the console URL or numeric ID","Validate the subscription format at config load time before constructing the platform","Keep project ID and subscription name in separate config fields if your deployment allows it"],"tags":["googlechat","gcp","pubsub","config"],"backgroundTag":"invalid-url-format","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}