Skip to content

fix(serverless-offline-sqs): resolve intrinsic & pseudo-parameter ARNs to a queueName (#200, #74)#270

Merged
silouone merged 3 commits into
masterfrom
fix/sqs-arn-resolution
Jun 20, 2026
Merged

fix(serverless-offline-sqs): resolve intrinsic & pseudo-parameter ARNs to a queueName (#200, #74)#270
silouone merged 3 commits into
masterfrom
fix/sqs-arn-resolution

Conversation

@silouone

Copy link
Copy Markdown
Member

Summary

extractQueueNameFromARN did a naive arn.split(':')[5], which silently produced arn:...:undefined for two common ARN shapes. ElasticMQ then rejects the poll with Missing required key 'QueueName' / MissingQueryParamRejection(QueueName), and the Lambda never fires.

Fix

A pure, exported resolveCfnValue flattens the intrinsic / pseudo-parameter forms an event arn can take — Ref, Fn::Join, Fn::Sub, and the #{AWS::X} / ${AWS::X} pseudo-parameters — into a plain string. The queue name is then taken as the final :-delimited segment of the resolved ARN, which is robust to any number of : the pseudo-parameters inject. The fragile switch('string') is replaced by an explicit branch that prefers an explicit queueName (the #211 override path) and otherwise derives it from the resolved ARN. A .fifo suffix is intentionally preserved.

Fn::GetAtt is already resolved to a string ARN upstream in index._resolveFn, so it deliberately has no branch here. Anything unresolvable offline (Fn::ImportValue, a Ref to a stack resource) returns undefined rather than throwing — the ARN stays visibly bad instead of silently wrong.

Behavior note: when an event sets both arn and queueName with different values, the explicit queueName now wins (the old code preferred arn). The README's documented example uses matching values, so no documented config changes.

Fixes #200
Fixes #74

Testing

Note: #189 (a FIFO .fifo queue-name vs ElasticMQ static-config mismatch) is a different root cause and is intentionally not claimed here — it belongs with the FIFO autocreate work.

🤖 Generated with Claude Code

@silouone silouone marked this pull request as ready for review June 20, 2026 18:50
@silouone silouone force-pushed the fix/sqs-arn-resolution branch from d6b5c75 to 98f5931 Compare June 20, 2026 18:55
silouone and others added 3 commits June 20, 2026 21:53
…s to a queueName

extractQueueNameFromARN did a naive `arn.split(':')[5]`, which broke for two
common ARN shapes and produced `arn:...:undefined` (ElasticMQ then rejects with
"Missing required key 'QueueName'"):

- #200 (sndr): an `arn` given as `{Fn::Join: [sep, parts]}` (with a nested
  `{Ref: AWS::AccountId}`) is an object, so the old `switch('string')` never
  reached extraction at all.
- #74 (DenisOgr): serverless-pseudo-parameters leaves `#{AWS::AccountId}` in the
  ARN string; the extra `::` it injects pushed split index [5] onto an empty
  segment.

Fix: a pure `resolveCfnValue` flattens the intrinsic / pseudo-parameter forms
(Ref / Fn::Join / Fn::Sub, `#{AWS::X}` and `${AWS::X}`) to a string, then the
queue name is taken as the final ':'-delimited segment (robust to any number of
injected ':'). The fragile `switch('string')` is replaced by an explicit branch
that prefers an explicit queueName (the #211 override path) and otherwise derives
it from the resolved ARN. A `.fifo` suffix is intentionally preserved.

Helpers are exported and unit-tested (10 new AVA cases incl. the exact #200/#74
repros).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…RN support (#74, #200)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ments

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@silouone silouone force-pushed the fix/sqs-arn-resolution branch from 98f5931 to 685d2cf Compare June 20, 2026 19:53
@silouone silouone merged commit c8015d0 into master Jun 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[serverless-offline-sqs] Missing QueueName [serverless-offline-sqs] Doesn't work with serverless-pseudo-parameters

1 participant