DanielAttard
DanielAttard

Reputation: 3615

Google Cloud Storage event trigger causes Too many overlapping notifications

I am trying to deploy a Google Cloud Function from Cloud Shell and a review of the logs shows the following error:

google.api_core.exceptions.BadRequest: 400 POST 
https://storage.googleapis.com/storage/v1/b/my-bucket/notificationConfigs? 
prettyPrint=false: Too many overlapping notifications. The maximum is 10.

The error is thrown when this code is triggered in response to a Cloud Storage event, specifically Finalize/Create of a new object.

def notifier(event, context):    
    print("""This Function was triggered by messageId {} published at {} to {}
    """.format(context.event_id, context.timestamp, context.resource["name"]))

    if 'data' in event:
        name = base64.b64decode(event['data']).decode('utf-8')
    else:
        name = 'World'
    print('Hello {}!'.format(name))

    storage_client = storage.Client()
    bucket = storage_client.bucket("my-bucket")
    notification = bucket.notification(topic_name="my-bucket-upload")
    notification.create()
    print(f"Successfully created notification with ID {notification.notification_id} for {bucket_name}")

I could find no reference to this error and I don't know what to try next. What could be causing this error message?

Upvotes: 0

Views: 429

Answers (1)

Gary Oak
Gary Oak

Reputation: 1

Hotfix: Remove notification.create() from that code.

Upvotes: 2

Related Questions