Serverless-offline: TypeError: Cannot read property 'Fn::Join' of undefined - undefined env vars

Created on 19 Jul 2020  路  1Comment  路  Source: dherault/serverless-offline

Bug Report

Current Behavior
You encounter the following exception if you use an environment variable without it being defined in the local shell:

Debug: internal, implementation, error
    TypeError: Cannot read property 'Fn::Join' of undefined
    at /Users/alexhayton/personal/stablemaster/lambda/node_modules/serverless-offline/dist/utils/resolveJoins.js:17:28
    at Array.forEach (<anonymous>)
    at resolveJoins (/Users/alexhayton/personal/stablemaster/lambda/node_modules/serverless-offline/dist/utils/resolveJoins.js:15:28)
    at new LambdaFunction (/Users/alexhayton/personal/stablemaster/lambda/node_modules/serverless-offline/dist/lambda/LambdaFunction.js:154:56)
    at LambdaFunctionPool.get (/Users/alexhayton/personal/stablemaster/lambda/node_modules/serverless-offline/dist/lambda/LambdaFunctionPool.js:93:24)
    at Lambda.get (/Users/alexhayton/personal/stablemaster/lambda/node_modules/serverless-offline/dist/lambda/Lambda.js:60:88)
    at hapiHandler (/Users/alexhayton/personal/stablemaster/lambda/node_modules/serverless-offline/dist/events/http/HttpServer.js:511:82)
    at module.exports.internals.Manager.execute (/Users/alexhayton/personal/stablemaster/lambda/node_modules/@hapi/hapi/lib/toolkit.js:41:33)
    at Object.internals.handler (/Users/alexhayton/personal/stablemaster/lambda/node_modules/@hapi/hapi/lib/handler.js:46:48)
    at exports.execute (/Users/alexhayton/personal/stablemaster/lambda/node_modules/@hapi/hapi/lib/handler.js:31:36)
    at Request._lifecycle (/Users/alexhayton/personal/stablemaster/lambda/node_modules/@hapi/hapi/lib/request.js:312:68)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at Request._execute (/Users/alexhayton/personal/stablemaster/lambda/node_modules/@hapi/hapi/lib/request.js:221:9)

Sample Code

  • file: serverless.yml
service: my-service

plugins:
  - serverless-offline

provider:
  runtime: nodejs12.x
  stage: dev
  environment:
    MY_ENV_VAR: ${env:MY_ENV_VAR}

functions:
  hello:
    events:
      - http:
          method: get
          path: hello
    handler: handler.hello
  • file: handler.js
'use strict'

const { stringify } = JSON

exports.hello = async function hello() {
  return {
    body: stringify({ foo: 'bar' }),
    statusCode: 200,
  }
}

Expected behavior/code
It should just deal with it

Environment

  • serverless version: v1.75.1
  • serverless-offline version: v6.5.0
  • node.js version: v12.16.1
  • OS: macOS 10.15.6

Possible Solution

https://github.com/dherault/serverless-offline/pull/1047

Most helpful comment

I also got this error, as stated in https://github.com/dherault/serverless-offline/pull/1047 it was due to an undefined environment variable in serverless.yml
After removing the var, the issue disapeared

>All comments

I also got this error, as stated in https://github.com/dherault/serverless-offline/pull/1047 it was due to an undefined environment variable in serverless.yml
After removing the var, the issue disapeared

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Dong9769 picture Dong9769  路  4Comments

jormaechea picture jormaechea  路  4Comments

FranzSkuffka picture FranzSkuffka  路  3Comments

ozbillwang picture ozbillwang  路  4Comments

aldofunes picture aldofunes  路  3Comments