Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'Fn::Join' of undefined - undefined env vars #1048

Closed
AlexHayton opened this issue Jul 19, 2020 · 1 comment

Comments

@AlexHayton
Copy link
Contributor

AlexHayton commented Jul 19, 2020

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

#1047

@WinstonN
Copy link

WinstonN commented Aug 8, 2020

I also got this error, as stated in #1047 it was due to an undefined environment variable in serverless.yml
After removing the var, the issue disapeared

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants