{"record":{"id":"b8824ebf99a2f96f","repo":"apache/seatunnel","slug":"connection-failed-b8824e","errorCode":"CONNECTION_FAILED","errorMessage":"Failed to create Google Pub/Sub publisher for topic ${topic}","messagePattern":"Failed to create Google Pub/Sub publisher for topic (.+?)","errorType":"error_code","errorClass":"GooglePubSubConnectorException","httpStatus":null,"severity":"critical","filePath":"seatunnel-connectors-v2/connector-google-pubsub/src/main/java/org/apache/seatunnel/connectors/seatunnel/google/pubsub/sink/GooglePubSubPublisher.java","lineNumber":86,"sourceCode":"                        .setCredentialsProvider(NoCredentialsProvider.create());\n            } else if (config.getCredentialsPath() != null) {\n                try (FileInputStream credentialsStream =\n                        new FileInputStream(config.getCredentialsPath())) {\n                    publisherBuilder.setCredentialsProvider(\n                            FixedCredentialsProvider.create(\n                                    GoogleCredentials.fromStream(credentialsStream)\n                                            .createScoped(\n                                                    PublisherStubSettings\n                                                            .getDefaultServiceScopes())));\n                }\n            }\n\n            return new GooglePubSubPublisher(publisherBuilder.build(), emulatorChannel);\n        } catch (Exception e) {\n            if (emulatorChannel != null) {\n                emulatorChannel.shutdownNow();\n            }\n            throw new GooglePubSubConnectorException(\n                    GooglePubSubConnectorErrorCode.CONNECTION_FAILED,\n                    \"Failed to create Google Pub/Sub publisher for topic \" + config.getTopic(),\n                    e);\n        }\n    }\n\n    @Override\n    public ApiFuture<String> publish(PubsubMessage message) {\n        return publisher.publish(message);\n    }\n\n    @Override\n    public void publishAllOutstanding() {\n        publisher.publishAllOutstanding();\n    }\n\n    @Override\n    public void close() throws IOException {","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-google-pubsub/src/main/java/org/apache/seatunnel/connectors/seatunnel/google/pubsub/sink/GooglePubSubPublisher.java#L68-L104","documentation":"Wrapped in GooglePubSubPublisher.create when the Pub/Sub Publisher builder fails (publisherBuilder.build() or related setup throws). The original exception is attached as the cause and the emulator channel (if used) is shut down before rethrowing as GooglePubSubConnectorException with code CONNECTION_FAILED. Most commonly this reflects authentication, credentials loading, or endpoint/channel problems.","triggerScenarios":"GooglePubSubPublisher.create(topic/config) fails during Publisher build: invalid credentials_path, unparseable service-account JSON, unreachable emulator host, bad project/topic name, or network failure reaching pubsub.googleapis.com.","commonSituations":"Missing or malformed service account key file, service account lacking pubsub.publisher role, running on-prem without outbound access to Google APIs, misconfigured emulator_host:port, or topic name typo.","solutions":["Inspect the wrapped cause exception — it names whether credentials, endpoint, or topic resolution failed.","Verify credentials_path points to a valid service-account JSON key whose service account has pubsub.publisher on the topic.","Confirm network access to pubsub.googleapis.com (or that the emulator host is reachable) and that the topic actually exists.","If using emulator_host together with credentials_path, remove one of them — they are mutually exclusive (see also the from() validation)."],"exampleFix":"// before\ncredentials_path = \"/wrong/path/key.json\"\n// after\ncredentials_path = \"/etc/secrets/pubsub-publisher-key.json\"","handlingStrategy":"try-catch","validationCode":"File keyFile = new File(credentialsPath);\nif (!keyFile.isFile()) throw new IllegalStateException(\"credentials_path does not exist: \" + credentialsPath);\n// Also check topic existence via a SubscriptionAdminClient before starting the job.","typeGuard":null,"tryCatchPattern":"try {\n    publisher = GooglePubSubPublisher.create(config);\n} catch (GooglePubSubConnectorException e) {\n    logger.error(\"Publisher creation failed ({}): {}\", e.getErrorCode(), e.getCause());\n    throw e; // fail fast; connection issues are usually not retryable inline\n}","preventionTips":["Pre-validate the credentials key file exists and is parseable JSON before job submit.","Grant the service account roles/pubsub.publisher on the topic.","Test connectivity to pubsub.googleapis.com (or the emulator) from the worker nodes.","Never set both credentials_path and emulator_host."],"tags":["google-pubsub","connection","authentication","java"],"backgroundTag":"connection-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}