serverless-step-functions icon indicating copy to clipboard operation
serverless-step-functions copied to clipboard

Latest version of plugin throws error with latest version of serverless framework

Open alexanderluiscampino opened this issue 4 years ago • 14 comments

Bug Report

Getting the following error:

Invalid variable reference syntax for variable . You can only reference env vars, options, & files. You can check our docs for more info.

image

This happens with the latest npm install --save-dev serverless-step-functions -> [email protected]

version: [email protected] does not have this issue.

serverless --version
Framework Core: 2.28.3
Plugin: 4.4.3
SDK: 2.3.2
Components: 3.7.1

Description

In very simple terms, this is my serverless.yml:

service: test-step-function

frameworkVersion: '2'

provider:
  name: aws
  runtime: python3.8
  lambdaHashingVersion: 20201221


plugins:
    - serverless-step-functions

functions:
  hello:
    handler: handler.hello

If the plugin section is commented out, the deployment goes through without a hitch. The absence of a stepFunction section is not a problem, nor it is needed. Simply including the plugin reference should not cause this to crash.

alexanderluiscampino avatar Mar 03 '21 03:03 alexanderluiscampino

Same issue here !!

But it's very strange as it was working before and suddenly stopped working and returning the same mentioned error

abdullahdarwish avatar Mar 03 '21 15:03 abdullahdarwish

Same issue here.

higorcoliveira avatar Mar 03 '21 15:03 higorcoliveira

Same issue

UPD: Updating serverless to 2.28.6 solved problem for me. Try sls upgrade

koskeller avatar Mar 03 '21 16:03 koskeller

after upgrading, i am getting the following error:

EDIT: just to clarify, i am using ${opt:stage} heavily throughout my project. it seems that if the line to import the serverless-step-functions plugin is present while using 2.28.6, i get this

EDIT2: after downgrading to [email protected], i can deploy once again

Type Error ---------------------------------------------

TypeError: Cannot read property 'stage' of undefined at Variables.getValueFromOptions (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:639:26) at Variables.getValueFromSource (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:579:17) at Variables.splitAndGet (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:448:17) at matches.map (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:387:40) at Array.map () at Variables.populateMatches (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:387:20) at Variables.populateValue (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:418:30) at properties.filter.map (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:300:38) at Array.map () at Variables.populateVariables (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:299:8) at Variables.populateObjectImpl (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:333:30) at initialCall (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:329:40) at Variables.initialCall (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:112:20) at Variables.populateObject (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:329:17) at parse.then.serverlessFileParam (/home/frank/Documents/PPS/PAS/Serverless/pas-serverless-gateway/public/node_modules/serverless-step-functions/lib/yamlParser.js:26:62)

serverless.yml

#[email protected] frameworkVersion: '2' service: test-project

provider: name: aws runtime: nodejs12.x timeout: 15 region: us-east-1 tracing: true

custom: test: ${opt:stage}-test

plugins:

  • serverless-step-functions

franklx2 avatar Mar 03 '21 19:03 franklx2

The update of 2.28.6 also solved this bug for me

capgadsx avatar Mar 03 '21 21:03 capgadsx

Not working with serverless 2.28.7, downgrade 2.28.0 fixed the issue

KrausMatthias avatar Mar 05 '21 11:03 KrausMatthias

after upgrading, i am getting the following error:

EDIT: just to clarify, i am using ${opt:stage} heavily throughout my project. it seems that if the line to import the serverless-step-functions plugin is present while using 2.28.6, i get this

EDIT2: after downgrading to [email protected], i can deploy once again

Type Error --------------------------------------------- TypeError: Cannot read property 'stage' of undefined at Variables.getValueFromOptions (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:639:26) at Variables.getValueFromSource (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:579:17) at Variables.splitAndGet (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:448:17) at matches.map (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:387:40) at Array.map () at Variables.populateMatches (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:387:20) at Variables.populateValue (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:418:30) at properties.filter.map (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:300:38) at Array.map () at Variables.populateVariables (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:299:8) at Variables.populateObjectImpl (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:333:30) at initialCall (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:329:40) at Variables.initialCall (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:112:20) at Variables.populateObject (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:329:17) at parse.then.serverlessFileParam (/home/frank/Documents/PPS/PAS/Serverless/pas-serverless-gateway/public/node_modules/serverless-step-functions/lib/yamlParser.js:26:62)

serverless.yml

#[email protected] frameworkVersion: '2' service: test-project provider: name: aws runtime: nodejs12.x timeout: 15 region: us-east-1 tracing: true custom: test: ${opt:stage}-test plugins:

  • serverless-step-functions

Same error here

gluix20 avatar Mar 12 '21 20:03 gluix20

Seeing a similar issue. It seems simply updating to these versions and including the plugin (with or without a stepFunctions section in the config) will generate an error

    "serverless": "^2.39.0",
    "serverless-step-functions": "^2.30.0",
 Serverless Error ----------------------------------------
 
  Trying to populate non string value into a string for variable ${sls:stage}. Please make sure the value of the property is a string.
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              14.16.1
     Framework Version:         2.39.0 (local)
     Plugin Version:            4.5.3
     SDK Version:               4.2.2
     Components Version:        3.9.1

razor-x avatar May 02 '21 22:05 razor-x

Same problem as @razor-x above when referencing the serverless-step-functions plugin.

Flavien avatar May 28 '21 23:05 Flavien

The same as well.

Pigius avatar Jul 10 '21 18:07 Pigius

This seems to be fixed in v3.0.0

carpusherw avatar Sep 14 '21 07:09 carpusherw

Same error in 3.19.0 this.serverless.variables.populateObject is not a function at /Users/xxxx/yyyy/zzzz/node_modules/serverless-step-functions/lib/yamlParser.js:26:62

sbinder avatar Jul 02 '22 02:07 sbinder

Its still the same in v3.

Will this be addressed? Am I missing something or can't we use step functions with v3 rn? Thanks for clarifying.

chris2k2 avatar Oct 02 '22 21:10 chris2k2

I was able to resolve this by updating the serverless-step-functions to v3.12.1

brunodamacena97 avatar Jan 31 '23 18:01 brunodamacena97