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

Environment Variables need to force Strings #128

Open
pickypg opened this issue Oct 23, 2018 · 1 comment · May be fixed by #136
Open

Environment Variables need to force Strings #128

pickypg opened this issue Oct 23, 2018 · 1 comment · May be fixed by #136

Comments

@pickypg
Copy link
Contributor

pickypg commented Oct 23, 2018

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"
@gretro
Copy link

gretro commented Oct 18, 2019

Updated the documentation as part of PR #6854 to limit the scope of the issue.

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

Successfully merging a pull request may close this issue.

3 participants