Skip to content

feat(resolver): resolve ${sls:stage}; aws: refs in fallbacks pass through; filters on resolve-later values error - #83

Merged
DavidWells merged 1 commit into
masterfrom
feat/sls-stage-aws-fallback
Oct 2, 2026
Merged

DavidWells merged 1 commit into
masterfrom
feat/sls-stage-aws-fallback

Conversation

@DavidWells

Copy link
Copy Markdown
Owner

Changes

  1. ${sls:stage} resolves the way Serverless does (osls get-sls.js): --stage, else provider.stage (a variable provider.stage resolves through it), else 'dev'. Other sls: addresses (instanceId) aren't matched, so they stay unknown-type passthrough. Fixes filters over fallbacks such as ${env:X, 'sl-${sls:stage}' | toUpperCase}, which now gives SL-QA.
  2. aws: / AWS:: refs inside fallbacks. The default syntax excludes ${aws:…}, ${AWS::…} and ${stageVariables…}. Nested inside another variable, they stopped that variable from matching at all: ${env:X, 'app-${aws:accountId}'} stayed unresolved even with X set. They're now kept as passthroughs in that position. Outside any variable (IAM ${aws:username}, ${aws:PrincipalTag/…}) they're unchanged.
  3. Filters over resolve-later values error. A filter on a value still holding an unknown type (${ssm:x}, ${aws:accountId}) used to be silently skipped; it now throws, naming the filter and the variable. A known type left unresolved under allowUnresolvedVariables still skips (the lenient behavior from cfcdac6).

Behavior changes in existing tests

  • passthroughInFallback (fix(resolver): unknown variable types inside a quoted fallback pass through #79) used ${sls:stage} as its example unknown type; it now uses ${sls:instanceId}.
  • duplicateVarFallback: ${opt:nope, ${AWS::Region}, 'us-east-1'} used to stay verbatim (the wrapping var never matched). It now resolves to ${AWS::Region} like any fallback list. Plain ${AWS::Region} copies are still verbatim.
  • serverlessGoldens: ${sls:stage} now shows the resolved stage; new aws: and instanceId fallback cases were added.

Tests

  • New tests/slsVariables (9) and tests/awsInFallback (9).
  • Full suite green; typecheck clean.

… through; filters on resolve-later values error

- ${sls:stage} resolves like Serverless (osls get-sls): --stage, else provider.stage, else
  'dev'. Other sls: addresses (instanceId) stay unknown-type passthrough.
- Refs the syntax excludes (${aws:...}, ${AWS::...}, ${stageVariables...}) inside another
  variable are kept as passthrough, so ${env:X, 'app-${aws:accountId}'} resolves (it blocked
  the whole value, even with X set). Outside any variable (IAM ${aws:username}) unchanged.
- A filter over a value still holding an unknown type (${ssm:x}, ${aws:accountId}) throws
  instead of silently skipping; known types left unresolved (allowUnresolvedVariables) still skip.

Tests: slsVariables (9), awsInFallback (9); passthroughInFallback uses ${sls:instanceId} as its
unknown type; duplicateVarFallback asserts a var wrapping ${AWS::Region} now resolves to it;
serverlessGoldens regenerated (sls:stage resolved; aws:/instanceId fallback cases added).
@DavidWells
DavidWells merged commit 6fdc97c into master Oct 2, 2026
4 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.

1 participant