Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError 'Attributes' in SQS _create_queue #2142

Open
SebCorbin opened this issue Oct 7, 2024 · 9 comments
Open

KeyError 'Attributes' in SQS _create_queue #2142

SebCorbin opened this issue Oct 7, 2024 · 9 comments

Comments

@SebCorbin
Copy link

We've got and intermittent error from where a task is sent create_export_task.delay() :

  File "celery/app/trace.py", line 760, in __protected_call__
    return self.run(*args, **kwargs)
  File "exports/tasks/export.py", line 32, in create_export_task
    run_export_task.delay(task.uuid)
  File "celery/app/task.py", line 444, in delay
    return self.apply_async(args, kwargs)
  File "celery/app/task.py", line 594, in apply_async
    return app.send_task(
  File "celery/app/base.py", line 798, in send_task
    amqp.send_task_message(P, name, message, **options)
  File "celery/app/amqp.py", line 517, in send_task_message
    ret = producer.publish(
  File "kombu/messaging.py", line 186, in publish
    return _publish(
  File "kombu/connection.py", line 556, in _ensured
    return fun(*args, **kwargs)
  File "kombu/messaging.py", line 202, in _publish
    [maybe_declare(entity) for entity in declare]
  File "kombu/messaging.py", line 202, in <listcomp>
    [maybe_declare(entity) for entity in declare]
  File "kombu/messaging.py", line 107, in maybe_declare
    return maybe_declare(entity, self.channel, retry, **retry_policy)
  File "kombu/common.py", line 113, in maybe_declare
    return _maybe_declare(entity, channel)
  File "kombu/common.py", line 153, in _maybe_declare
    entity.declare(channel=channel)
  File "kombu/entity.py", line 617, in declare
    self._create_queue(nowait=nowait, channel=channel)
  File "kombu/entity.py", line 626, in _create_queue
    self.queue_declare(nowait=nowait, passive=False, channel=channel)
  File "kombu/entity.py", line 655, in queue_declare
    ret = channel.queue_declare(
  File "kombu/transport/virtual/base.py", line 538, in queue_declare
    return queue_declare_ok_t(queue, self._size(queue), 0)
  File "kombu/transport/SQS.py", line 660, in _size
    return int(resp['Attributes']['ApproximateNumberOfMessages'])
KeyError: 'Attributes'

Versions

kombu==5.3.7
celery==5.3.4
amqp==5.2.0
boto3==1.34.128
botocore==1.34.128

Here's the payload returned by c.get_queue_attributes()

{
  ResponseMetadata: {
    HTTPHeaders: {
      connection: "keep-alive",
      content-length: "0",
      content-type: "application/x-amz-json-1.0",
      date: "Sat, 05 Oct 2024 22:00:00 GMT",
      x-amzn-requestid: "..."
    },
    HTTPStatusCode: 200,
    RequestId: "...",
    RetryAttempts: 0
  }
}

The queue is already created before that, another thing is that create_export_task is itself a task (which calls run_export_task) but I don't know if that's relevant, as the error is intermittent

@adiberk
Copy link

adiberk commented Oct 20, 2024

Hitting this also

@abomariam
Copy link

Downgrade to botocore==1.34.89 version, it may fix your issue.

@rwhit
Copy link

rwhit commented Mar 20, 2025

Also seeing this. Any plans to fix? Downgrading botocore is not a viable long-term solution.

@auvipy
Copy link
Member

auvipy commented Mar 22, 2025

we got some new fixes in SQS, lets see if they fix this. @hfern what do you think?

@hfern
Copy link
Contributor

hfern commented Mar 22, 2025

@rwhit Can you post the exact installed version of celery, kombu, and botocore?

@rwhit
Copy link

rwhit commented Mar 23, 2025

celery: 5.3.6
kombu: 5.3.7
botocore: 1.34.134

@abomariam
Copy link

abomariam commented Mar 24, 2025

In botocore 1.34.90 they used the AWS JSON protocol
boto/botocore@1.34.89...1.34.90
boto/botocore@47a515f

Kombu is sending the attribute to retrieve the ApproximateReciveCount like this 'AttributeName.1': 'ApproximateReceiveCount'
The new way expects an array named AttributeNames instead.

Kombu updated this in this commit
7e501a0

And they reverted it here.
1dfe4f3

@hfern
Copy link
Contributor

hfern commented Mar 24, 2025

@rwhit Thank you for posting the versions. Can you upgrade to kombu==5.5.0 ? We added support for the SQS JSON protocol in 5.5.

@auvipy
Copy link
Member

auvipy commented Mar 25, 2025

I believe this should be fixed with kombu 5.5.1 release, but let me know if that is not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants