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
- 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).
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
- 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.
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
- Failed to open AmazonDocumentDB source reader for database [
- Option 'field_delimiter' cannot be empty
- Option '${option}' cannot be blank
- Option '${option}' must be greater than 0
- Failed to close Google Pub/Sub publisher
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/b8824ebf99a2f96f.
Report an issue: GitHub.