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

ERROR: (gcloud.run.deploy) argument --set-env-vars: Bad syntax for dict arg #560

Open
marceljm opened this issue Apr 13, 2022 · 5 comments
Assignees

Comments

@marceljm
Copy link

marceljm commented Apr 13, 2022

During a deploy to Cloud Run, I'm trying to set the Environment Variables field like this:

KEY1:value1
KEY2:value2,value3

But I'm having this error:

Failed to deploy the app. Error: ERROR: (gcloud.run.deploy) argument --set-env-vars: Bad syntax for dict arg: [value3]. Please see gcloud topic flags-file or gcloud topic escaping for information on providing list or dictionary flag values with special characters. ,Usage: gcloud run deploy [[SERVICE] --namespace=NAMESPACE] [optional flags] optional flags may be --add-cloudsql-instances | --allow-unauthenticated | --args | --async | --binary-authorization | --breakglass | --clear-binary-authorization | --clear-cloudsql-instances | --clear-config-maps | --clear-env-vars | --clear-key | --clear-labels | --clear-post-key-revocation-action-type | --clear-secrets | --clear-vpc-connector | --cluster | --cluster-location | --command | --concurrency | --connectivity | --context | --cpu | --cpu-throttling | --env-vars-file | --help | --image | --ingress | --key | --kubeconfig | --labels | --max-instances | --memory | --min-instances | --namespace | --platform | --port | --post-key-revocation-action-type | --region | --remove-cloudsql-instances | --remove-config-maps | --remove-env-vars | --remove-labels | --remove-secrets | --revision-suffix | --service-account | --set-cloudsql-instances | --set-config-maps | --set-env-vars | --set-secrets | --source | --tag | --timeout | --no-traffic | --update-config-maps | --update-env-vars | --update-labels | --update-secrets | --use-http2 | --vpc-connector | --vpc-egress For detailed information on this command and its flags, run: gcloud run deploy --help

So it seems the comma needs to be escaped, but I had no success with quotation marks or backslash. How to make this work?

@etanshaul
Copy link

Hi. I work on the IntelliJ extension and we have a similar issue.

Did you, by any chance, try entering the all of the env vars into a single field in the VS Code UI (with the custom delimiter as required by Cloud Run for dictionary values)? This does not work in IntelliJ due to the way it is parsed, but I am not sure if it would in VSC (untested).

One solution we are considering is supporting the --env-vars-file flag which will allow you to point to a file on disk containing all of your env vars (and you'd avoid having to mess with the delimiters). Would this approach work for you?

@marceljm
Copy link
Author

Hi, @etanshaul

Could you provide examples, please? Or maybe documentation links. I don't know exactly how to do this in Cloud Code.

  1. "entering the all of the env vars into a single field in the VS Code UI"
  2. "supporting the --env-vars-file flag".

@etanshaul
Copy link

I will try out (1) later. It is more of a work around, and not ideal at all. (and like I said, doesn't work in IJ, so I suspect it won't work here either).

For (2) disregard, sorry. Cloud Run actually does not support this flag (https://ahmet.im/blog/mastering-cloud-run-environment-variables/).

We'll need to investigate this within the team to find the best solution.

@marceljm
Copy link
Author

For now I could solve that by making "Environment Variables" UI field empty and using a Dockerfile to set the variables. This syntax works:

ENV KEY1='value1'
ENV KEY2='value2,value3'

@kschaab
Copy link
Contributor

kschaab commented Apr 19, 2022

We'll slate this for a fix by passing the values to gcloud in a different way.

@kschaab kschaab self-assigned this Apr 19, 2022
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

4 participants
@etanshaul @kschaab @marceljm and others