mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
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:
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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user