functions-framework-java icon indicating copy to clipboard operation
functions-framework-java copied to clipboard

Environment variables in pom.xml results in error

Open martijnschouwe opened this issue 5 years ago • 6 comments

In the pom.xml we defined the environment variables like this:
<environmentVariables> <CUTOFF_TIME>18</CUTOFF_TIME> <SHIPPING_DURATION>1</SHIPPING_DURATION> <SUNDAY_SORTING>false</SUNDAY_SORTING> <SKIPPED_DAYS>MONDAY,THURSDAY,SUNDAY</SKIPPED_DAYS> </environmentVariables>

When running functions:deploy the following error occurs: Jun 18, 2020 2:17:23 PM com.google.cloud.tools.appengine.operations.Gcloud runCommand SEVERE: ERROR: (gcloud.functions.deploy) argument --set-env-vars: Bad syntax for dict arg: [THURSDAY]. Please see gcloud topic flags-file or gcloud topic escaping for information on providing list or dictionary flag values with special characters. Usage: gcloud functions deploy (NAME : --region=REGION) [optional flags] optional flags may be --allow-unauthenticated |

The command executed is: Executing Cloud SDK command: gcloud functions deploy getKrisKrasDeliveryWindows --region=europe-west4 --trigger-http --allow-unauthenticated --entry-point=com.example.KrisKrasHttp --source=target/deploy --set-env-vars=CUTOFF_TIME=18,SHIPPING_DURATION=1,SKIPPED_DAYS=MONDAY,THURSDAY,SUNDAY,SUNDAY_SORTING=false --runtime=java11 --project=xxx

According to the documentation gcloud functions deploy FUNCTION_NAME --set-env-vars FOO=bar FLAGS...

The first = sign needs to be removed. So --set-env-vars instead of --set-env-vars=

martijnschouwe avatar Jun 18 '20 12:06 martijnschouwe

Looking...

ludoch avatar Jun 18 '20 15:06 ludoch

Which documentation do you follow? https://cloud.google.com/sdk/gcloud/reference/functions/deploy#--set-env-vars shows the = separator which does not work?

So 2 bugs: doc and plugin?

ludoch avatar Jun 18 '20 17:06 ludoch

Nop we need to add [] but then we have another issue with SKIPPED_DAYS=MONDAY,THURSDAY,SUNDAY which is seen a bad list of env vars without values (ie MONDAY without a value). Need to understand how escaping this works.

ludoch avatar Jun 18 '20 17:06 ludoch

This is the only issue, no need for [], but this one SKIPPED_DAYS=MONDAY,THURSDAY,SUNDAY is the one causing parsing issue. If you put only 1 item, then the plugin works.

ludoch avatar Jun 18 '20 17:06 ludoch

Cloud SDK escaping rules are https://cloud.google.com/sdk/gcloud/reference/topic/escaping so I guess it is a user error in defining in the pom.xml a value with ',' which does not have the good escaping magic...

ludoch avatar Jun 18 '20 17:06 ludoch

Is it a user error? Normally in a pom you define a map or an array as described in this topic. The parsing part is done by this library. So the translation from pom values is not correct imho. Another option is to document how maps and arrays should be defined in a pom in order to work with this library. On the other hand your digressing from standards

martijnschouwe avatar Jun 19 '20 08:06 martijnschouwe

Closing issue since there is no follow-up. Please feel free to reopen if the issue persists.

janell-chen avatar Sep 27 '23 23:09 janell-chen