Version(s) affected
I am using 1.4.1
Description
SqsTransportNameResolver maps the Lambda event's eventSourceARN back to a configured Messenger transport, but both of its matching strategies assume the standard aws partition:
// Rebuild SQS ARN from https://sqs.eu-west-3.amazonaws.com/0123456789/messages?key=value
if (preg_match('/^https:\/\/sqs\.([^.]+)\.amazonaws\.com\/([^\/]+)\/([^?]+)/', (string) $dsn, $matches)) { ... }
- The regex only matches
amazonaws.com queue URLs — the AWS European Sovereign Cloud (partition aws-eusc, region eusc-de-east-1) uses amazonaws.eu (and the China partition uses amazonaws.com.cn).
- The rebuilt ARN hardcodes the
arn:aws: prefix, while the incoming event carries the actual partition, e.g. arn:aws-eusc:sqs:eusc-de-east-1:123456789012:my-queue. So even if the URL regex matched, the comparison would still fail for any non-aws partition (including aws-cn and aws-us-gov).
Result when a message is consumed:
InvalidArgumentException: No transport found for eventSource
"sqs://arn:aws-eusc:sqs:eusc-de-east-1:123456789012:my-queue".
(src/Service/Sqs/SqsTransportNameResolver.php:44)
The exact-match strategy ($dsn === 'sqs://' . $eventSourceArn) can't be used as an escape hatch either, because an ARN-shaped sqs:// DSN is not parseable by symfony/amazon-sqs-messenger on the sending side.
How to reproduce
- Deploy a Symfony app with
bref/symfony-messenger in an AWS partition other than aws — e.g. the European Sovereign Cloud (eusc-de-east-1).
- Configure the SQS transport DSN (queue URL form or
sqs://host/account/queue?region=… form) and wire the queue to SqsConsumer as usual.
- Send any message to the queue → the consumer throws
No transport found for eventSource "sqs://arn:aws-eusc:…".
Possible solution
Instead of rebuilding a full ARN with a hardcoded partition, compare the components: extract (region, account, queue) from the eventSourceARN (arn:<partition>:sqs:<region>:<account>:<queue>) and from the DSN, and match on those. That makes the resolver partition-agnostic and also covers future partitions/URL suffixes without further regex maintenance. Alternatively, relax the URL regex to any suffix and take the arn:<partition>: prefix from the event's own ARN.
Workaround
Pin the transport name explicitly so the resolver is never consulted (works when the app has a single SQS transport):
# config/services.yaml
Bref\Symfony\Messenger\Service\Sqs\SqsConsumer:
public: true
autowire: true
arguments:
$transportName: "async"
Additional context
The sending side has the same partition assumption in symfony/amazon-sqs-messenger (AmazonSqsTransportFactory::supports() and Connection::fromDsn() only accept amazonaws.com); reported separately to symfony/symfony.
Version(s) affected
I am using 1.4.1
Description
SqsTransportNameResolvermaps the Lambda event'seventSourceARNback to a configured Messenger transport, but both of its matching strategies assume the standardawspartition:amazonaws.comqueue URLs — the AWS European Sovereign Cloud (partitionaws-eusc, regioneusc-de-east-1) usesamazonaws.eu(and the China partition usesamazonaws.com.cn).arn:aws:prefix, while the incoming event carries the actual partition, e.g.arn:aws-eusc:sqs:eusc-de-east-1:123456789012:my-queue. So even if the URL regex matched, the comparison would still fail for any non-awspartition (includingaws-cnandaws-us-gov).Result when a message is consumed:
The exact-match strategy (
$dsn === 'sqs://' . $eventSourceArn) can't be used as an escape hatch either, because an ARN-shapedsqs://DSN is not parseable bysymfony/amazon-sqs-messengeron the sending side.How to reproduce
bref/symfony-messengerin an AWS partition other thanaws— e.g. the European Sovereign Cloud (eusc-de-east-1).sqs://host/account/queue?region=…form) and wire the queue toSqsConsumeras usual.No transport found for eventSource "sqs://arn:aws-eusc:…".Possible solution
Instead of rebuilding a full ARN with a hardcoded partition, compare the components: extract
(region, account, queue)from theeventSourceARN(arn:<partition>:sqs:<region>:<account>:<queue>) and from the DSN, and match on those. That makes the resolver partition-agnostic and also covers future partitions/URL suffixes without further regex maintenance. Alternatively, relax the URL regex to any suffix and take thearn:<partition>:prefix from the event's own ARN.Workaround
Pin the transport name explicitly so the resolver is never consulted (works when the app has a single SQS transport):
Additional context
The sending side has the same partition assumption in
symfony/amazon-sqs-messenger(AmazonSqsTransportFactory::supports()andConnection::fromDsn()only acceptamazonaws.com); reported separately to symfony/symfony.