apache/seatunnel · critical · GooglePubSubConnectorException

CONNECTION_FAILED

CONNECTION_FAILED

Error message

Failed to create Google Pub/Sub publisher for topic ${topic}

What it means

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.

Source

Thrown at seatunnel-connectors-v2/connector-google-pubsub/src/main/java/org/apache/seatunnel/connectors/seatunnel/google/pubsub/sink/GooglePubSubPublisher.java:86

                        .setCredentialsProvider(NoCredentialsProvider.create());
            } else if (config.getCredentialsPath() != null) {
                try (FileInputStream credentialsStream =
                        new FileInputStream(config.getCredentialsPath())) {
                    publisherBuilder.setCredentialsProvider(
                            FixedCredentialsProvider.create(
                                    GoogleCredentials.fromStream(credentialsStream)
                                            .createScoped(
                                                    PublisherStubSettings
                                                            .getDefaultServiceScopes())));
                }
            }

            return new GooglePubSubPublisher(publisherBuilder.build(), emulatorChannel);
        } catch (Exception e) {
            if (emulatorChannel != null) {
                emulatorChannel.shutdownNow();
            }
            throw new GooglePubSubConnectorException(
                    GooglePubSubConnectorErrorCode.CONNECTION_FAILED,
                    "Failed to create Google Pub/Sub publisher for topic " + config.getTopic(),
                    e);
        }
    }

    @Override
    public ApiFuture<String> publish(PubsubMessage message) {
        return publisher.publish(message);
    }

    @Override
    public void publishAllOutstanding() {
        publisher.publishAllOutstanding();
    }

    @Override
    public void close() throws IOException {

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Inspect the wrapped cause exception — it names whether credentials, endpoint, or topic resolution failed.
  2. Verify credentials_path points to a valid service-account JSON key whose service account has pubsub.publisher on the topic.
  3. Confirm network access to pubsub.googleapis.com (or that the emulator host is reachable) and that the topic actually exists.
  4. If using emulator_host together with credentials_path, remove one of them — they are mutually exclusive (see also the from() validation).

Example fix

// before
credentials_path = "/wrong/path/key.json"
// after
credentials_path = "/etc/secrets/pubsub-publisher-key.json"
Defensive patterns

Strategy: try-catch

Validate before calling

File keyFile = new File(credentialsPath);
if (!keyFile.isFile()) throw new IllegalStateException("credentials_path does not exist: " + credentialsPath);
// Also check topic existence via a SubscriptionAdminClient before starting the job.

Try / catch

try {
    publisher = GooglePubSubPublisher.create(config);
} catch (GooglePubSubConnectorException e) {
    logger.error("Publisher creation failed ({}): {}", e.getErrorCode(), e.getCause());
    throw e; // fail fast; connection issues are usually not retryable inline
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/b8824ebf99a2f96f. Report an issue: GitHub.