chore(serverless-offline-sqs): allow passing queueName from config#211
Closed
mfamilia wants to merge 1 commit into
Closed
chore(serverless-offline-sqs): allow passing queueName from config#211mfamilia wants to merge 1 commit into
mfamilia wants to merge 1 commit into
Conversation
imphatic
approved these changes
Oct 13, 2023
|
Any plans on merging this @godu? It would be very helpful to get |
|
+1 @godu |
1 similar comment
|
+1 @godu |
|
another +1 to merging this in 🙂 |
|
+1 @godu, it would be very useful to get this in |
silouone
added a commit
that referenced
this pull request
Jun 19, 2026
…ueName fixes - Serverless v4 logger migration (src/log.js shim threaded into the SQS emulator). - Fix undefined this.region -> this.options.region so emitted events carry awsRegion. Re-implements #166 (thanks @zlalvani). - Make SQS deleteMessageBatch entry Ids unique within a batch (index-based, <=80 chars). Re-implements #253 (thanks @flipscholtz). - Add custom.serverless-offline-sqs.queueName override (non-mutating; strips arn so it wins for arn-bearing shapes). Re-implements #211 (thanks @mfamilia). - Backward compatible with serverless v3. Adds docker-free unit tests. v8.1.0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Member
silouone
added a commit
that referenced
this pull request
Jun 20, 2026
…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>
silouone
added a commit
that referenced
this pull request
Jun 20, 2026
…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>
silouone
added a commit
that referenced
this pull request
Jun 20, 2026
…listener per queue (#262) A single SQS event mapping may target multiple queues via a `queueName` that is an array (`[appLogsQueue, ediProcessingQueue]`) or a comma-separated string (`'a,b,c'`, e.g. the `--queueName a,b` CLI form), at the event level or via the `custom.serverless-offline-sqs.queueName` override. Previously `create()` ran exactly one `_create` per event, so an array/comma `queueName` was String-coerced into a single malformed queue (`'appLogsQueue,ediProcessingQueue'`) and no second listener was ever created (#262, reported by renanlido). Fix (sqs.js only — the SQSEventDefinition ARN-extraction path from #74/#200/#211 is already correct and is left untouched): - normalizeQueueNames(spec) -> string[]: pure lodash/fp helper that normalizes a scalar / comma-separated / array `queueName` into a trimmed, de-duplicated, empty-dropped list; nullish/empty/whitespace input returns [] without throwing (preserves origin/master's non-throwing contract — the issue's proposed `throw new Error('missing queueName or arn')` is intentionally NOT applied). - expandSqsEventDefinitions(options, rawDef) -> def[]: fans a raw event definition out into one definition per resolved queue name. The override wins and strips `arn`/`queueName` so SQSEventDefinition rebuilds the ARN from the override (the #211 contract). A scalar `queueName` yields exactly one def (zero behavior change for existing single-queue configs). An ARN string or `{arn}`/intrinsic object with no literal `queueName` is passed straight through as a single listener, so extractQueueNameFromARN/resolveCfnValue keeps owning name derivation (#74/#200). - create() now fans out via expandSqsEventDefinitions before _create; _create receives a fully-resolved single-queue definition. resolveQueueName stays exported (its #211 tests remain green) but is no longer wired into _create. Adds 14 unit tests covering scalar/array/comma forms, override precedence, de-dup, prop preservation, immutability, and the ARN single-listener guards. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
silouone
added a commit
that referenced
this pull request
Jun 20, 2026
…listener per queue (#262) A single SQS event mapping may target multiple queues via a `queueName` that is an array (`[appLogsQueue, ediProcessingQueue]`) or a comma-separated string (`'a,b,c'`, e.g. the `--queueName a,b` CLI form), at the event level or via the `custom.serverless-offline-sqs.queueName` override. Previously `create()` ran exactly one `_create` per event, so an array/comma `queueName` was String-coerced into a single malformed queue (`'appLogsQueue,ediProcessingQueue'`) and no second listener was ever created (#262, reported by renanlido). Fix (sqs.js only — the SQSEventDefinition ARN-extraction path from #74/#200/#211 is already correct and is left untouched): - normalizeQueueNames(spec) -> string[]: pure lodash/fp helper that normalizes a scalar / comma-separated / array `queueName` into a trimmed, de-duplicated, empty-dropped list; nullish/empty/whitespace input returns [] without throwing (preserves origin/master's non-throwing contract — the issue's proposed `throw new Error('missing queueName or arn')` is intentionally NOT applied). - expandSqsEventDefinitions(options, rawDef) -> def[]: fans a raw event definition out into one definition per resolved queue name. The override wins and strips `arn`/`queueName` so SQSEventDefinition rebuilds the ARN from the override (the #211 contract). A scalar `queueName` yields exactly one def (zero behavior change for existing single-queue configs). An ARN string or `{arn}`/intrinsic object with no literal `queueName` is passed straight through as a single listener, so extractQueueNameFromARN/resolveCfnValue keeps owning name derivation (#74/#200). - create() now fans out via expandSqsEventDefinitions before _create; _create receives a fully-resolved single-queue definition. resolveQueueName stays exported (its #211 tests remain green) but is no longer wired into _create. Adds 14 unit tests covering scalar/array/comma forms, override precedence, de-dup, prop preservation, immutability, and the ARN single-listener guards. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Seems like this functionality was once supported (see PR)
I've found that allowing
queueNameto be overridden via configuration can help address issues with other plugins (e.g. Lift - getlift/lift#101)Feedback welcomed!