Skip to content

Serverless should throw error when resolution of a variable crashes #3367

Description

@eahefnawy

Note: This report was initially about throwing an error if non existing file is referenced in a variable. It was updated to cover all failed variable resolution cases

Ideally we should fail unconditionally whenever resolution of a variable from a source crashes.
Note that fallbacks should be applied if no value was resolved (null or undefined), but not when resolution crashes.

Cases it should cover (by variables scope):

  • file: Pointing non existing file
  • cf, s3, ssm: Inability to retrieve the data (network or authentication error)
  • env: Not set environment variable

Proposed implementation

  1. Introduce a configuration option: unresolvedVariablesNotificationMode with two possible options 'warn' (default) and 'error' (In v2 we will make 'error' a default)
  2. Throw on unresolved variables if unresolvedVariablesNotificationMode is set to 'error'
  3. Introduce a following deprecation log if there are unresolved variables in a service, and service configuration doesn't contain unresolvedVariablesNotificationMode:
Unresolved variable references will be communicated with a thrown error, starting from next major 

See https://github.com/serverless/serverless/blob/master/CONTRIBUTING.md#configuring-deprecations for info on how to configure deprecations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions