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

SQS Queue instance from resource API returns empty attributes #4109

Closed
chophilip21 opened this issue Apr 30, 2024 · 3 comments
Closed

SQS Queue instance from resource API returns empty attributes #4109

chophilip21 opened this issue Apr 30, 2024 · 3 comments
Assignees
Labels
bug This issue is a confirmed bug. p2 This is a standard priority issue response-requested Waiting on additional information or feedback. sqs

Comments

@chophilip21
Copy link

Describe the bug

The change in the behavior has been introduced starting boto 1.34.90

Here is a demo code:

local_config = {'VisibilityTimeout': 60,
 'MaximumMessageSize': 262144,
 'MessageRetentionPeriod': 1209600,
 'DelaySeconds': 0,
 'ReceiveMessageWaitTimeSeconds': 20}

resource = boto3.resource("sqs", **credentials._asdict())

queue = resource.create_queue(QueueName=name, Attributes=local_config)
print(queue.attributes)

We are passing in Attributes when creating_queue, so that we can call queue.attributes down the line. I have tried similar approach using the client api (SQS.Client.get_queue_attributes) as well, but the attributes are still not visible, regardless of specifying AttributeNames to all.

Expected Behavior

Up until version 1.34.89, we were getting correct response for queue.attributes like the following:

{'ApproximateNumberOfMessagesDelayed': '0', 'VisibilityTimeout': '90', 'ApproximateNumberOfMessagesNotVisible': '0', 'LastModifiedTimestamp': '1714509875', 'QueueArn': 'arn:aws:sqs:elasticmq:000000000000:dummy_queue', 'CreatedTimestamp': '1714509875', 'ApproximateNumberOfMessages': '0', 'ReceiveMessageWaitTimeSeconds': '20', 'DelaySeconds': '0'}
Now the response is just empty dict. Expected behavior is to have all the attributes like the previous versions.

Current Behavior

There is no error message, warning, or anything. Suddenly behaviors have changed to return an empty dictionary.

Reproduction Steps

On the latest version of boto3 and botocore (anything above 1.34.89 actually), run:

local_config = {'VisibilityTimeout': 60,
 'MaximumMessageSize': 262144,
 'MessageRetentionPeriod': 1209600,
 'DelaySeconds': 0,
 'ReceiveMessageWaitTimeSeconds': 20}

resource = boto3.resource("sqs", **credentials._asdict())
queue = resource.create_queue(QueueName=name, Attributes=local_config)
queue.attributes

Possible Solution

Something might be happening with the visibility of the attributes. But I do not see a way to control this under resources api.

Additional Information/Context

No response

SDK version used

1.34.94

Environment details (OS name and version, etc.)

Ubuntu 20.04.6 LTS

@chophilip21 chophilip21 added bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged. labels Apr 30, 2024
@RyanFitzSimmonsAK RyanFitzSimmonsAK self-assigned this Apr 30, 2024
@RyanFitzSimmonsAK RyanFitzSimmonsAK added investigating This issue is being investigated and/or work is in progress to resolve the issue. sqs p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Apr 30, 2024
@RyanFitzSimmonsAK
Copy link
Contributor

Hi @chophilip21, thanks for reaching out. I'm having some trouble reproducing this behavior. When I run your reproduction script on version 1.34.95, the response includes attributes.

local_config = {
    'VisibilityTimeout': '60',
    'MaximumMessageSize': '262144',
    'MessageRetentionPeriod': '1209600',
    'DelaySeconds': '0',
    'ReceiveMessageWaitTimeSeconds': '20'
}

resource = boto3.resource("sqs")

queue = resource.create_queue(QueueName='myTestQueue', Attributes=local_config)
print(queue.attributes)
{'QueueArn': myQueueArn, 'ApproximateNumberOfMessages': '0', 'ApproximateNumberOfMessagesNotVisible': '0', 'ApproximateNumberOfMessagesDelayed': '0', 'CreatedTimestamp': '1714518237', 'LastModifiedTimestamp': '1714518237', 'VisibilityTimeout': '60', 'MaximumMessageSize': '262144', 'MessageRetentionPeriod': '1209600', 'DelaySeconds': '0', 'ReceiveMessageWaitTimeSeconds': '20', 'SqsManagedSseEnabled': 'true'}

When I use GetQueueAttributes, I similarly have no issues.

client = boto3.client('sqs')

response = client.get_queue_attributes(
    AttributeNames = ['All'],
    QueueUrl='https://sqs.us-west-2.amazonaws.com/604627212573/myTestQueue'
)

print(response)
{'Attributes': {'QueueArn': myQueueArn, 'ApproximateNumberOfMessages': '0', 'ApproximateNumberOfMessagesNotVisible': '0', 'ApproximateNumberOfMessagesDelayed': '0', 'CreatedTimestamp': '1714518237', 'LastModifiedTimestamp': '1714518237', 'VisibilityTimeout': '60', 'MaximumMessageSize': '262144', 'MessageRetentionPeriod': '1209600', 'DelaySeconds': '0', 'ReceiveMessageWaitTimeSeconds': '20', 'SqsManagedSseEnabled': 'true'}...

Am I misunderstanding the issue in some way? If not, could you provide debug logs? You can get debug logs by adding boto3.set_stream_logger('') to the top of your script, and redacting any sensitive information. Thanks!

@RyanFitzSimmonsAK RyanFitzSimmonsAK added response-requested Waiting on additional information or feedback. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Apr 30, 2024
@chophilip21
Copy link
Author

Apologies, I realized that the behavior changes were introduced because of our local testing involving ElasticMQ. When I tested endpoints against our production SQS service, seems like there is no issues nor any changes. Thank you for looking into this!

Copy link

github-actions bot commented May 1, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a confirmed bug. p2 This is a standard priority issue response-requested Waiting on additional information or feedback. sqs
Projects
None yet
Development

No branches or pull requests

2 participants