From b20e4d656a964fd8c200e32046e7b3bbc30d7801 Mon Sep 17 00:00:00 2001 From: dgross881 Date: Fri, 5 Jun 2026 16:38:14 +0800 Subject: [PATCH] fix(gax): use string field names for Tesla.Multipart Tesla.Multipart expects string field/file names. Convert atom names to strings via to_string/1 and use "metadata" instead of :metadata. --- clients/gax/lib/google_api/gax/connection.ex | 27 ++++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/clients/gax/lib/google_api/gax/connection.ex b/clients/gax/lib/google_api/gax/connection.ex index 1b7e95edfe..e4cc568b07 100644 --- a/clients/gax/lib/google_api/gax/connection.ex +++ b/clients/gax/lib/google_api/gax/connection.ex @@ -178,22 +178,27 @@ defmodule GoogleApi.Gax.Connection do {meta, body_params} = extract_metadata(body_params) - body = case meta do - nil -> body - _ -> Tesla.Multipart.add_field( - body, - :metadata, - Poison.encode!(meta), - headers: [{:"Content-Type", "application/json"}] - ) - end + body = + case meta do + nil -> + body + + _ -> + Tesla.Multipart.add_field( + body, + "metadata", + Poison.encode!(meta), + headers: [{:"Content-Type", "application/json"}] + ) + end body = Enum.reduce(body_params, body, fn {body_name, data}, b -> {res, type} = try_encode_multipart_field(data, meta) + Tesla.Multipart.add_field( b, - body_name, + to_string(body_name), res, headers: [{:"Content-Type", type}] ) @@ -201,7 +206,7 @@ defmodule GoogleApi.Gax.Connection do body = Enum.reduce(file_params, body, fn {file_name, file_path}, b -> - Tesla.Multipart.add_file(b, file_path, name: file_name) + Tesla.Multipart.add_file(b, file_path, name: to_string(file_name)) end) Keyword.put(output, :body, body)