fix(sqs): accept bare queue name in QueueUrl field (#980)

AWS SQS resolves a plain queue name (e.g. "TestQueue") to the full queue URL transparently. Floci required the full URL, causing  NonExistentQueue errors for clients that pass only the name - a pattern common in AWS SDK for Java v2 applications.

Add normalizeQueueUrl() which expands bare names to the canonical {baseUrl}/{accountId}/{queueName} form before storage-key computation, covering all SQS operations that accept a QueueUrl parameter.
This commit is contained in:
dagrammy authored and GitHub committed 2026-05-21 20:35:12 -05:00
1 parent be4eba1c20
commit ff40a2fc0a
2 files changed
+47 -4

No files matched your search

@@ -1257,12 +1257,29 @@ public class SqsService {
* default account.
*/
public String senderIdFor(String queueUrl) {
String fromUrl = accountFromQueueUrl(queueUrl);
String fromUrl = accountFromQueueUrl(normalizeQueueUrl(queueUrl));
return fromUrl != null ? fromUrl : regionResolver.getAccountId();
}
private static String regionKey(String region, String queueUrl) {
return region + "::" + extractQueuePath(queueUrl);
/**
* Accepts a full queue URL or a bare queue name and returns a canonical
* full URL. AWS SQS allows clients to pass either form in the QueueUrl
* field; this mirrors that behavior so lookups succeed regardless of what
* the caller supplied.
*/
private String normalizeQueueUrl(String queueUrl) {
if (queueUrl == null) {
return null;
}
if (queueUrl.contains("://")) {
return queueUrl;
}
// Bare queue name — construct the full URL the same way createQueue does.
return baseUrl + "/" + regionResolver.getAccountId() + "/" + queueUrl;
}
private String regionKey(String region, String queueUrl) {
return region + "::" + extractQueuePath(normalizeQueueUrl(queueUrl));
}
/**
@@ -1299,7 +1316,7 @@ public class SqsService {
*/
private Optional<Queue> getQueueByUrl(String storageKey, String queueUrl) {
if (queueStore instanceof AccountAwareStorageBackend<Queue> aware) {
String accountId = accountFromQueueUrl(queueUrl);
String accountId = accountFromQueueUrl(normalizeQueueUrl(queueUrl));
if (accountId != null) {
return aware.getForAccount(accountId, storageKey);
}