yiisoft/yii2-queue

problem with TTR parameter and AWS SQS queue

mfrattola opened this issue · 2 comments

What steps will reproduce the problem?

I have a fifo queue on AWS SQS service.

When I try to queue an element to the queue, I receive this error from the AWS SDK

yii\base\ErrorException: The provided type for MessageAttributes -> TTR -> StringValue value was integer. The modeled type is string. in /var/www/html/pmstore/vendor/aws/aws-sdk-php/src/QueryCompatibleInputMiddleware.php:165

What's expected?

that the element would be queued

What do you get instead?

the error listed above

I notice that at line 200 of \vendor\yiisoft\yii2-queue\src\drivers\sqs\Queue.php

'MessageAttributes' => [
'TTR' => [
'DataType' => 'Number',
'StringValue' => $ttr,
],
],

If I cast $ttr to string, it works as expected

Additional info

Q A
Yii version 2.0.49.3
PHP version 7.4
Operating system Debian 11
AWS SDK 3.304.4

Honestrly I don't understand. The fix seems to have been already applied, but the file I downloaded with composer don't have the fix.

from the composer.lock file

"name": "yiisoft/yii2-queue",
"version": "2.3.6",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/yii2-queue.git",
"reference": "5c14c3f6e83b2e2d150a969dc6eda4e083b73956"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/yii2-queue/zipball/5c14c3f6e83b2e2d150a969dc6eda4e083b73956",
"reference": "5c14c3f6e83b2e2d150a969dc6eda4e083b73956",
"shasum": ""
},

and the code in question is

'MessageAttributes' => [
'TTR' => [
'DataType' => 'Number',
'StringValue' => $ttr,
],
],

Try dev-master - this fix has not been released yet.