Google cloud upload fails in dev env, but works locally

Hello Friends, I have a phoenix app up in GCP k8s in a dev env. I have an image uploader that has been working in the past and suddenly stopped working. I am making a request to upload an image to a google cloud bucket, this is the code

  def upload_image_file(image_file_struct, path) do
    {:ok, token} = Goth.Token.for_scope("")
    bucket = Application.get_env(:beswick, Beswick)[:image_bucket]
    conn =

    case GoogleApi.Storage.V1.Api.Objects.storage_objects_insert_simple(
           Application.get_env(:beswick, Beswick)[:image_bucket],
             name: "cc_catalogs/Beswick/#{path}/#{Path.basename(image_file_struct.filename)}",
             contentType: "image/jpeg"
         ) do
      {:ok, result} ->
        IO.inspect("made it this far")
        # changeset
        # |> cast(%{image_url: image_file_struct.filename}, [
        #   :image_url
        # ])

        {:ok, image_file_struct.filename}

      error ->
        IO.inspect("FILE UPLOAD ERROR")

        {:error, error}

When I call the storage_objects_insert_simple The connections terminates and returns a 500.

INFO 2024-04-09T01:41:01.146749942Z [resource.labels.containerName: product-manager] 01:41:01.144 [info] Sent 500 in 1245ms
INFO 2024-04-09T01:41:01.148383022Z [resource.labels.containerName: product-manager] 01:41:01.144 [error] #PID<0.3390.0> running BeswickWeb.Endpoint (connection #PID<0.3197.0>, stream id 3) terminated

I am not sure why, this code runs locally but does not errors in dev. Any help would be greatly appreciated

Hi, can you provide the full error stacktrace?

1 Like

Here is the full stack trace

INFO 2024-04-09T12:17:10.379959181Z [resource.labels.containerName: product-manager] 12:17:10.377 [info] Sent 500 in 6501ms
INFO 2024-04-09T12:17:10.380945281Z [resource.labels.containerName: product-manager] 12:17:10.377 [error] #PID<0.3331.0> running BeswickWeb.Endpoint (connection #PID<0.3330.0>, stream id 1) terminated
INFO 2024-04-09T12:17:10.380962909Z [resource.labels.containerName: product-manager] Server: (http)
INFO 2024-04-09T12:17:10.380967563Z [resource.labels.containerName: product-manager] Request: POST /update-product-version
INFO 2024-04-09T12:17:10.380990641Z [resource.labels.containerName: product-manager] ** (exit) an exception was raised:
INFO 2024-04-09T12:17:10.380995529Z [resource.labels.containerName: product-manager] ** (MatchError) no match of right hand side value: {:error, :enoent}
INFO 2024-04-09T12:17:10.380999171Z [resource.labels.containerName: product-manager] (public_key 1.14) pubkey_os_cacerts.erl:38: :pubkey_os_cacerts.get/0
INFO 2024-04-09T12:17:10.381002923Z [resource.labels.containerName: product-manager] (inets 9.0.1) httpc.erl:476: :httpc.ssl_verify_host_options/1
INFO 2024-04-09T12:17:10.381006949Z [resource.labels.containerName: product-manager] (inets 9.0.1) httpc.erl:1015: anonymous fn/0 in :httpc.http_options_default/0
INFO 2024-04-09T12:17:10.381010588Z [resource.labels.containerName: product-manager] (inets 9.0.1) httpc.erl:961: :httpc.http_options/3
INFO 2024-04-09T12:17:10.381014318Z [resource.labels.containerName: product-manager] (inets 9.0.1) httpc.erl:771: :httpc.handle_request/9
INFO 2024-04-09T12:17:10.381017867Z [resource.labels.containerName: product-manager] (tesla 1.8.0) lib/tesla/adapter/httpc.ex:52: Tesla.Adapter.Httpc.request/2
INFO 2024-04-09T12:17:10.381021395Z [resource.labels.containerName: product-manager] (tesla 1.8.0) lib/tesla/adapter/httpc.ex:22:
INFO 2024-04-09T12:17:10.381025717Z [resource.labels.containerName: product-manager] (tesla 1.8.0) lib/tesla/middleware/compression.ex:154:
INFO 2024-04-09T12:17:11.357889995Z [resource.labels.containerName: product-manager] 12:17:11.356 [info] GET /

I see the {:error, enote} impliying that the file does not exist, but I also see that the connection gets terminated before that. I am also not sure why we would get an enote on dev but not locally.

Also, thank you for your help @benwilson512

I suspect you updated OTP version to 25+ ?
Try to downgrade to the previous used version (or the version you are using on dev).

As for why this might happen, starting from OTP-25 this functionality was introduced: Erlang/OTP 25 Highlights - Erlang/OTP

1 Like

I had to change my otp version, thank you bossman!