serverless-graphql-nodejs-starter icon indicating copy to clipboard operation
serverless-graphql-nodejs-starter copied to clipboard

Serverless Error: Trying to populate non string value into a string for variable ${self:custom.stage}. Please make sure the value of the property is a string.

Open daniulChowdhury opened this issue 4 years ago • 5 comments

Screen Shot 2020-12-27 at 10 57 06 pm

Hi Amo,

I encounter this issue as I follow the instructions from your tutorial: https://fsgql.com/set-up-seed

Do you have any advice on how to solve this?

Regards,

Daniul

daniulChowdhury avatar Dec 27 '20 11:12 daniulChowdhury

Hey @daniulChowdhury , have you managed to come right with this issue?

AmoDinho avatar Jan 25 '21 11:01 AmoDinho

same here

wagnercsfilho avatar Feb 17 '21 22:02 wagnercsfilho

@wagnercsfilho

This usually happens when ${self:custom.stage} is not defined in your serverless.yml. Make sure you have stage defined under the custom block, something like this:

custom:
  stage: ${opt:stage, self:provider.stage}

If you don't already have a custom block in your serverless.yml, add it to your serverless.yml above the provider block. If you do already have one, add the stage: ${opt:stage, self:provider.stage} to the block.

Be sure to watch out for indention. There are no spaces before custom:, and two spaces before stage: ${opt:stage, self:provider.stage}.

AmoDinho avatar Feb 18 '21 06:02 AmoDinho

@AmoDinho

Solve this bug with the config below.

provider:
  stage: dev
custom:
  stage: ${opt:stage, self:provider.stage}

However, several successive errors are happening.

Captura de Tela 2021-02-18 às 15 14 44

Captura de Tela 2021-02-18 às 15 14 36

wagnercsfilho avatar Feb 18 '21 18:02 wagnercsfilho

@wagnercsfilho Bruv, can you make sure your serverless.yml looks like this:

service: lunar-tour-api

# Use the serverless-webpack plugin to transpile ES6
plugins:
  - serverless-bundle
  - serverless-offline
  - serverless-dotenv-plugin

# serverless-webpack configuration
# Enable auto-packing of external modules
custom:
  stage: ${opt:stage, self:provider.stage}
  region: ${opt:region, self:provider.region}

  serverless-offline:
    port: 4000
  bundle:
    linting: false

provider:
  name: aws
  runtime: nodejs12.x
  stage: dev
  region: us-east-1


functions:
  graphql:
    handler: src/graphql.graphqlHandler
    environment:
      SLS_DEBUG: true
    events:
      - http:
          path: graphql
          method: post
          cors: true
          integration: lambda-proxy

      - http:
          path: graphql
          method: get
          cors: true
          integration: lambda-proxy



Please let me know how it goes 🦖

AmoDinho avatar Feb 18 '21 19:02 AmoDinho