serverless/serverless-google-cloudfunctions

Environment Variables need to force Strings

Open

#128 创建于 2018年10月23日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)JavaScript (124 fork)auto 404
help wanted

仓库指标

Star
 (275 star)
PR 合并指标
 (PR 指标待抓取)

描述

After updating to 2.1.0 for environment variable support, I ran into an unexpected issue where an environment variable, which is an integer, was rejected by GCF and thus prevented deployment of my function because it wasn't passed to GCF as a string.

{
  "ResourceType": "cloudfunctions.v1beta2.function",
  "ResourceErrorCode": "400",
  "ResourceErrorMessage": {
    "code": 400,
    "message": "Invalid value at 'function.environment_variables[0].value' (TYPE_STRING), 10",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "function.environment_variables[0].value",
            "description": "Invalid value at 'function.environment_variables[0].value' (TYPE_STRING), 10"
          }
        ]
      }
    ],
    "statusMessage": "Bad Request",
    "requestPath": "...",
    "httpMethod": "PUT"
  }
}

The code that _.merge's environment variables should probably call .toString on everything.

Workaround

Simply force the environment variable in your YAML to be a string by wrapping it with quotes.

    environment:
      VARIABLE: "10"

贡献者指南