Skip to main content

Fixing Cloud Build / Cloud Run Error: argument --set-env-vars: Bad syntax for dict arg

Here is hot you can Fix Cloud Build / Cloud Run Error: argument --set-env-vars: Bad syntax for dict arg

While deploying a service to Google Cloud Run through Cloud Build, I ran into this error:

ERROR: (gcloud.run.deploy) argument --set-env-vars: 
Bad syntax for dict arg: [http://localhost:3000].

At first glance, the deployment config looked fine. I was passing multiple allowed origins like this:

ALLOWED_ORIGINS=https://example-app.run.app,http://localhost:3000,http://localhost:3001

✅ What caused the error?

Cloud Run’s --set-env-vars flag splits values using commas.
Since the environment variable itself contained commas, Cloud Run thought I was trying to define new variables:

  • https://example-app.run.app

  • http://localhost:3000

  • http://localhost:3001

So it broke parsing and threw the error.


 The first try: wrap the value in quotes

Just add quotes around the value:

ALLOWED_ORIGINS="https://example-app.run.app,http://localhost:3000,http://localhost:3001",

Nothing changes — Couple of dev suggested this but this is not a woking solution.


✅ Working fix: escape commas using ^@^

Instead of quoting (which surprisingly did not work for Cloud Build), the fix was to escape the commas using a safe placeholder (^@^), like this:

ALLOWED_ORIGINS=^@@^https://example.run.app,http://localhost:3000,http://localhost:3001



🎉 Result

✅ Cloud Run accepts the variable
✅ No syntax error
✅ Your app still gets a proper list of origins


Comments

Popular posts from this blog

When Should Developers Use AI to Plan vs Just Start Coding?

When and How Should Developers Use AI — Plan First or Start Generating Code? Last week, a developer on our team opened an AI tool before writing a single line of code. The task? Change a button label. A few minutes later, the AI had suggested architecture improvements, refactoring strategies, testing layers, and performance considerations… for a one-line change. We laughed. But it revealed something important: Using AI isn’t the challenge anymore. Knowing  when and how  to use it is. The Real Decision: Generate Code or Think First? Today, developers face a new daily choice: Should I ask AI to generate code right away… or should I use AI to help me plan first? Starting with code feels fast. It gives you that dopamine hit of "done." But without clarity, rapid generation often leads to rework, hidden bugs, and "spaghetti code" that just happens to be syntax-perfect. Great developers use AI differently. They decide  whether the problem needs thinking or typing . A memor...

Sending Emails in Laravel with Gmail SMTP

This post will help you to fix issue like  Error : Swift_TransportException in StreamBuffer . php line 268 : Connection could not be established with host smtp . gmail . com [ Connection refused #111] Sending emails is crucial for any web application. Usually, an email is sent to notify the user of some kind of activity.Here are the steps to send email in laravel using Gmail SMTP. Generally Gmail is not recommended to send emails on live server, but if you just using it for testing purpose then follow these steps: 1. Visit   https://myaccount.google.com/security   make sure you have allowed  less secure app  to YES. 2. Unlock captcha on  https://accounts.google.com/b/0/DisplayUnlockCaptcha . 3. Generate APP password  Turn on 2-Step Verification for your account  https://myaccount.google.com/security. Your app might not support the latest security standards. Try changing a few settings to allow less secure...

Complete guide: integrating POSTGIS with Laravel

PostGIS - It is an open-source software extension for the PostgreSQL relational database management system. It enables support for geographic objects and spatial queries, making it a powerful tool for working with geographic information systems (GIS) data. PostGIS allows you to store, manipulate, and analyze spatial data, such as points, lines, polygons, and other geometric objects. How to Setup PostGIS with Laravel To set up PostGIS with Laravel, you'll need to follow a few steps. PostGIS is an extension for PostgreSQL that allows you to work with geospatial data, and Laravel is a popular PHP framework. Before proceeding, ensure you have PostgreSQL installed on your server or local development environment. Here's a step-by-step guide to setting up PostGIS with Laravel: 1. Install Laravel: If you haven't already, install Laravel using Composer. Open your terminal and run the following command: composer create-project --prefer-dist laravel/laravel project-name 2. Configure...