Skip to content

Environment Variables need to force Strings #128

Open
@pickypg

Description

@pickypg

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"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions