Skip to content

Fix: Support fallback values for ${param:x, fallback} syntax in stage parameters #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2025

Conversation

yashptel
Copy link
Contributor

@yashptel yashptel commented Jun 5, 2025

Summary

This PR restores support for default/fallback values in ${param:...} variable resolution syntax using the comma-separated fallback notation:

${param:some_non_existent_parameter, 'subnet-0123456789'}

Previously, this behavior was supported in Serverless Framework (especially via Compose), but recent versions of the OSS fork began throwing errors when the primary param could not be resolved.

Issue

Given this input:

provider:
  environment:
    sample_ecr_subnet: ${param:some_non_existent_parameter, 'subnet-0123456789'}

Users encountered:

Error: The param "some_non_existent_parameter" cannot be resolved from stage params...

This breaks compatibility with [the documented variable syntax](https://www.serverless.com/framework/docs/guides/variables#default-values) and behavior users depend on, especially when running through Compose.

Fix

  • Updated param resolution logic to support fallback values when primary param is not defined.

  • Removed hard-coded error throw on missing param and allowed fallback substitution.

  • Fixes Default values (${x,y} syntax) don't work if param x is not defined #56

  • Added tests:

    • Ensures fallback is used when the param is missing.
    • Confirms normal substitution when the param is available.
    • Verifies the new error code MISSING_VARIABLE_RESULT for unsupported formats.

@mnapoli
Copy link
Contributor

mnapoli commented Jun 5, 2025

Thanks!

@mnapoli mnapoli merged commit a53cfa8 into oss-serverless:main Jun 5, 2025
3 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.

Default values (${x,y} syntax) don't work if param x is not defined
3 participants