martide / arc_gcs

Provides an Arc backend for Google Cloud Storage
Apache License 2.0
46 stars 27 forks source link

Bad Request after upgrade to 0.2.0 #83

Open pierot opened 4 years ago

pierot commented 4 years ago

We recently bumped arc_gcs to 0.2. We have some code uploading data each night to Google Cloud Storage. It has been working flawlessly with 0.1.2 for a long time. But after our upgrade we get the following:

result = Segment.store(%{filename: filename, binary: some_data})

Results in:

{
  :error, 
  [
      %Tesla.Env{
        __client__: %Tesla.Client{
          adapter: nil,
          fun: nil,
          post: [],
          pre: [
            {Tesla.Middleware.Headers, :call, [[{"authorization", "Bearer XXX"}]]}
          ]
        },
        __module__: GoogleApi.Storage.V1.Connection,
        body: "Missing end boundary in multipart body.",
        headers: [
          {"date", "Wed, 18 Dec 2019 08:36:20 GMT"},
          {"server", "UploadServer"},
          {"content-length", "39"},
          {"content-type", "text/plain; charset=utf-8"},
          {"x-guploader-uploadid", "XXX"},
          {"alt-svc",
           "quic=\":443\"; ma=2592000; v=\"46,43\",h3-Q050=\":443\"; ma=2592000,h3-Q049=\":443\"; ma=2592000,h3-Q048=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000"}
        ],
        method: :post,
        opts: [],
        query: [uploadType: "multipart", predefinedAcl: "private"],
        status: 400,
        url: "https://www.googleapis.com/upload/storage/v1/b/XXX/o"
      }
    ]
}

With the following error:

[warn] Received unexpected :ssl data on {:sslsocket, {:gen_tcp, #Port<0.2762>, :tls_connection, :undefined}, [#PID<0.2852.0>, #PID<0.2851.0>]}
   Data:       "HTTP/1.0 400 Bad Request\r\nContent-Type: text/html; charset=UTF-8\r\nReferrer-Policy: no-referrer\r\nContent-Length: 1555\r\nDate: Wed, 18 Dec 2019 08:36:20 GMT\r\n\r\n<!DOCTYPE html>\n<html lang=en>\n  <meta charset=utf-8>\n  <meta name=viewport content=\"initial-scale=1, minimum-scale=1, width=device-width\">\n  <title>Error 400 (Bad Request)!!1</title>\n  <style>\n    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}\n  </style>\n  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>\n  <p><b>400.</b> <ins>That’s an error.</ins>\n  <p>Your client has issued a malformed or illegal request.  <ins>That’s all we know.</ins>\n"
   MFA:        :undefined
   Request:    :undefined
   Session:    {:session, {{'www.googleapis.com', 443}, #PID<0.2850.0>}, false, :https, {:sslsocket, {:gen_tcp, #Port<0.2762>, :tls_connection, :undefined}, [#PID<0.2852.0>, #PID<0.2851.0>]}, {:essl, []}, 1, :keep_alive, true}
   Status:     :keep_alive
   StatusLine: :undefined
   Profile:    :httpc_manager
ammbot commented 4 years ago

@pierot Would you mind sharing your definition file?

pierot commented 4 years ago
defmodule XXX.Uploaders.Segment do
  use Arc.Definition

  @versions [:original]

  def bucket, do: "XXX"

  def gcs_object_headers(:original, _map), do: [content_type: "text/csv"]

  def storage_dir(_version, {_file, _scope}), do: "segments/"
end
ammbot commented 4 years ago

@pierot this error is happen every time or for specific file? I'm trying to reproduce this. but no luck.

pierot commented 4 years ago

@ammbot I get this every time. The file is a csv as binary.