kestra-io / plugin-gcp

Apache License 2.0
6 stars 10 forks source link

PubSub Consume task fails with NullPointerException when no subscription is provided #350

Open shrutimantri opened 6 months ago

shrutimantri commented 6 months ago

Expected Behavior

When no subscription is provided, PubSub Consume task should automatically create a subscription as specified in the description of the subscription attribute.

Actual Behaviour

When no subscription is provided, PubSub Consume task fails with NullPointerException.

Here is the stacktrace:

2024-03-23 15:59:18.522 java.lang.NullPointerException
    at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:903)
    at com.google.pubsub.v1.ProjectSubscriptionName.<init>(ProjectSubscriptionName.java:57)
    at com.google.pubsub.v1.ProjectSubscriptionName.<init>(ProjectSubscriptionName.java:29)
    at com.google.pubsub.v1.ProjectSubscriptionName$Builder.build(ProjectSubscriptionName.java:157)
    at com.google.pubsub.v1.ProjectSubscriptionName.of(ProjectSubscriptionName.java:61)
    at io.kestra.plugin.gcp.pubsub.AbstractPubSub.createSubscription(AbstractPubSub.java:45)
    at io.kestra.plugin.gcp.pubsub.Consume.run(Consume.java:84)
    at io.kestra.plugin.gcp.pubsub.Consume.run(Consume.java:29)
    at io.kestra.core.runners.Worker$WorkerThread.run(Worker.java:710)

Steps To Reproduce

  1. Take the example flow, and put in appropriate values.
  2. Do not add the subscription attribute to the task.
  3. Execute the task. The execution fails with NullPointerException.

I also tried by adding autoCreateSubscription: true, but still the same error.

Environment Information

Example flow

id: pubsub-consume
namespace: dev
tasks:
  - id: "consume"
    type: "io.kestra.plugin.gcp.pubsub.Consume"
    projectId: <project-id>
    serviceAccount: "{{ secret('GCP_SERVICE_ACCOUNT_JSON') }}"
    topic: smantri-test
    maxRecords: 3