You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Trying to populate non string value into a string for variable #3714
What went wrong?
I updated to the latest version of Serverless and I'm now getting an error when I invoke functions locally without adding the stage option in the command line.
What did you expect should have happened?
The function should have been executed without an issue using the default stage as it was set up in the serverless.yml
provider:
name: aws
stage: dev
custom:
stage: ${opt:stage, self:provider.stage}
What was the config you used?
OS: darwin
Node Version: 6.10.3
Serverless Version: 1.14.0
What stacktrace or error message from your provider did you see?
Serverless Warning --------------------------------------
A valid option to satisfy the declaration 'opt:stage'
could not be found.
Serverless Error ---------------------------------------
Trying to populate non string value into a string for
variable ${opt:stage}. Please make sure the value of
the property is a string.
Stack Trace --------------------------------------------
ServerlessError: Trying to populate non string value into a string for variable ${opt:stage}. Please make sure the value of the property is a string.
at Variables.populateVariable (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:143:17)
at singleValueToPopulate.then.valueToPopulate (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:109:23)
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
Reacted by Otto Jongerius, John Lewis, Ashwin Balamohan, Alexey Boklin, Giorgi, Connor Leech, Ashwin Vaswani, Roger Avery and Kamil Albrycht
@pmuens@eahefnawy This could be an additional issue with the new variable system. This example uses the defaults notation (${..., ...}). Nevertheless the issue should be verified independently first.
Just run in to the same issue. Trying to work around the fact you can't specify Fn::GetAtt as an arn for the authorizer. So instead, I created three different ARNs in my custom section, and then used this:
This seems to work ok on my mac, but when I run it on CI/CD (linux) it fails with the same error:
A valid option to satisfy the declaration 'opt:stage' could not be found.
Ah.. i'm using 1.13.2 on my mac, whereas the CI/CD server is running 1.14.0... that might explain it, especially if @HyperBrain mentioned the "new variable system"?
Ok "fixed" this... the config command I was running doesn't need a --stage but the way I had set up my yml meant it would complain if it's not there...
So I added --stage to the config command which fixed things..
Reacted by Pedro Larroy, Mykola Radionov, ca-pli, kiran01bm, Scott Williams, Dmitry Grinko, Sean Patrick Murphy, vcamejo-pit, Giorgi and Connor Leech
I'm new to serverless and just got this same error when trying to login. Is there a fix here or something I need to configure to login and run deployments?
$ serverless login
Serverless Warning --------------------------------------
A valid option to satisfy the declaration 'opt:stage' could not be found.
Serverless Error ---------------------------------------
Trying to populate non string value into a string for variable ${opt: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: darwin
Node Version: 8.9.1
Framework Version: 1.67.0
Plugin Version: 3.6.3
SDK Version: 2.3.0
Components Version: 2.28.0
Reacted by Shail Choksi, bitttttten, Gordon Seidoh Worley, Jonathan, MUJAWARANJUM9598, Daniel Aniszkiewicz, Deniz and Gabriel Castilho
Activity
HyperBrain commentedon May 31, 2017
@pmuens @eahefnawy This could be an additional issue with the new variable system. This example uses the defaults notation (
${..., ...}). Nevertheless the issue should be verified independently first.pmuens commentedon Jun 1, 2017
@elioncho @HyperBrain thanks for reporting and investigating.
Yes, it looks like smth. is broken there 🤔 Should be easy to reproduce...
jliebrand commentedon Jun 8, 2017
Just run in to the same issue. Trying to work around the fact you can't specify Fn::GetAtt as an arn for the authorizer. So instead, I created three different ARNs in my custom section, and then used this:
This seems to work ok on my mac, but when I run it on CI/CD (linux) it fails with the same error:
A valid option to satisfy the declaration 'opt:stage' could not be found.
jliebrand commentedon Jun 8, 2017
Ah.. i'm using 1.13.2 on my mac, whereas the CI/CD server is running 1.14.0... that might explain it, especially if @HyperBrain mentioned the "new variable system"?
jliebrand commentedon Jun 8, 2017
Just upgraded both to 1.15.1 and still the same: this works on my mac, but not on linux
jliebrand commentedon Jun 8, 2017
Tried all of these invocations, none work:
--stage production
--stage=production
--stage="production"
Without the ${opt:stage} things do work (in that it deploys to app-[stage]). So I'm guessing on linux it just doesn't populate the "opt" struct?
jliebrand commentedon Jun 8, 2017
Aahhh.. this seems to be a problem with how i'm invoking serverless on CI/CD... I'm doing this:
serverless config credentials --provider aws --key KEYXXX --secret SECRETXXX && serverless deploy --stage dev
This breaks assumptions made in CLI.js I think...
jliebrand commentedon Jun 8, 2017
Ok "fixed" this... the config command I was running doesn't need a --stage but the way I had set up my yml meant it would complain if it's not there...
So I added --stage to the config command which fixed things..
pmuens commentedon Jun 13, 2017
Thanks for sharing the steps to reproduce @jliebrand 👍
/cc @eahefnawy @brianneisler 🔝
pmuens commentedon Feb 7, 2019
Closing since this is quite a stale issue and we've published newer versions with lots of fixes for this in the past.
Feel free to re-open if this is still an issue.
dmitry-grinko commentedon Jul 20, 2019
if you are using
${opt:stage}you should runsls deploy --stage devconnor11528 commentedon Apr 3, 2020
I'm new to serverless and just got this same error when trying to login. Is there a fix here or something I need to configure to login and run deployments?
Neeraj-Almabetter commentedon Aug 27, 2024
anyone got any solution?