cloud-code-intellij
cloud-code-intellij copied to clipboard
Error while running code cloud - cloud run
I am using IntelliJ to locally run and debug the cloud run however I am getting an expected error while running the app. In the environment variables section, I specify a profiles key with a comma separate value. however, it seems to cause the error -
Note - rest all other values for the key are singular.
Upon running it generates the following error -
Can someone please help me to resolve this issue? I am using the Windows operating system having IntelliJ installed.
@beena-yatin-kanyal thanks for reporting. To confirm - when you don't include that env var, you don't get that error?
Similar question - if you only include a single profile, e.g. only dev
, does it do what is expected?
I did some more investigation. it appears to be an issue with how the values are passed to the gcloud alpha code export
command which is used under the hood:
I also came across this post which might help: https://ahmet.im/blog/mastering-cloud-run-environment-variables/
~~I haven't validated it, but one option is to try setting the value as follows in the IDE: 'external internal private dev'
. Note the single quote and the space instead of commas.~~ This didn't work, I tested it myself. Will update if I find the solution.
Another option (also from the linked blog post above), would be to use the --env-vars-file
flag and link to a file which contains the values you want. Not ideal, but it should unblock you.
@beena-yatin-kanyal thanks for reporting. To confirm - when you don't include that env var, you don't get that error?
Similar question - if you only include a single profile, e.g. only
dev
, does it do what is expected?
Hi, @etanshaul please find the answers -
[1] - If I don't include the spring_profile_active environment variable the application won't work expectedly as the profiles won't get active and hence the restful endpoint communication will fail. [2] - If I include a single value to the spring_profile_active environment variable (let say 'dev') the plugin works fine but in this case, I will have to run the cloud run plugin 4 times for each profile (i.e. external, internal, private, and dev) and each run will have a different port. Now, this looks fine but from the development perspective, it is a bit tedious as I will have to map somewhere that which profile/endpoint is running on which port (which honestly I would like to avoid).
Another option (also from the linked blog post above), would be to use the
--env-vars-file
flag and link to a file that contains the values you want. Not ideal, but it should unblock you.
Thanks, @etanshaul. Yes, I explored this option last night and was able to run the cloud run locally with the help of the below command -
gcloud beta code dev SERVICE_CONFIG_FILE --dockerfile=Dockerfile --local-port=10097 --application-default-credential
but it lacks the debugging capability that the plugin provides. The SERVICE_CONFIG_FILE represents the YAML available at the link specified above. Can we please look into the possibility of adding support to the environment file to the plugin for local debugging and probably look into the original issue (by some escaping, etc)?
Yes, I explored this option last night and was able to run the cloud run locally with the help of the below command -
gcloud beta code dev SERVICE_CONFIG_FILE --dockerfile=Dockerfile --local-port=10097 --application-default-credential
Yeah, you're totally right that right now the plugin doesn't support passing in the --env-vars-file
flag. We look into adding a field to support this flag so that you can point to a file. We'll also see if there is a clean way to handle the structured env var UI with proper escaping etc.
Will keep this issue open to track and update you accordingly.
[2] - If I include a single value to the spring_profile_active environment variable (let say 'dev') the plugin works fine but in this case, I will have to run the cloud run plugin 4 times for each profile (i.e. external, internal, private, and dev) and each run will have a different port. Now, this looks fine but from the development perspective, it is a bit tedious as I will have to map somewhere that which profile/endpoint is running on which port (which honestly I would like to avoid).
right right. I was refreshing my memory on spring profiles to see if there is a way to compose profiles (e.g. create a new profile called "all" that you can compose of all other profiles - that way we get around the list value, just to unblock you for now). But I didn't find anything.
Yes, I explored this option last night and was able to run the cloud run locally with the help of the below command -
gcloud beta code dev SERVICE_CONFIG_FILE --dockerfile=Dockerfile --local-port=10097 --application-default-credential
Yeah, you're totally right that right now the plugin doesn't support passing in the
--env-vars-file
flag. We look into adding a field to support this flag so that you can point to a file. We'll also see if there is a clean way to handle the structured env var UI with proper escaping etc.Will keep this issue open to track and update you accordingly.
Thanks, @etanshaul. Looking forward to the new update. Cheers and a happy new year.
Kamino cloned this issue to GoogleCloudPlatform/cloud-code-intellij-internal