Skip to content

opentelemetry_finch: BadMapError, expected a map, got: {...} #555

@DaemonSnake

Description

@DaemonSnake

Describe the bug
An api call is failing and opentelemetry_finch raises a BadMapError when it happens

Expected behavior
Not to crash, at worst ignore it, at best parse it correctly

Additional context
Callstack look something like so:

lib/opentelemetry_finch.ex in OpentelemetryFinch.handle_request_stop/4 at line 44
/app/deps/telemetry/src/telemetry.erl in anonymous fn/4 in :telemetry.execute/3 at line 167
lists.erl in :lists.foreach_1/2 at line 2641
/app/deps/telemetry/src/telemetry.erl in :telemetry.span/3 at line 327
lib/req/finch.ex in Req.Finch.finch_stream_into_collectable/5 at line 155
lib/req/request.ex in Req.Request.run_request/1 at line 1118
lib/req/request.ex in Req.Request.run/1 at line 1062

And the failing argument like so:

    {{[
        [""] |
        "{\n  \"error\": {\n    \"code\": 404,\n    \"message\": \"File not found: ....\",\n    \"errors\": [\n      {\n        \"message\": \"File not found: ....\",\n        \"domain\": \"global\",\n        \"reason\": \"notFound\",\n        \"location\": \"fileId\",\n        \"locationType\": \"parameter\"\n      }\n    ]\n  }\n}\n"
      ], #Function<0.75527955/2 in Collectable.BitString.into/1>},
     %Req.Request{
       method: :get,
       url: URI.parse("https://www.googleapis.com/drive/v3/files/..."),
       headers: %{
         "accept-encoding" => ["gzip"],
         "authorization" => ["Bearer ..."],
         "content-type" => ["application/json; charset=utf-8"],
         "user-agent" => ["req/0.5.15"]
       },
       body: nil,
       options: %{
         auth: {:bearer,
          "..."},
         finch: ...,
         params: [mimeType: "application/pdf"],
         retry: false,
         receive_timeout: 15000,
         base_url: "https://www.googleapis.com",
         finch_private: [log_on_error_only: true]
       },
       halted: false,
       adapter: &Req.Steps.run_finch/1,
       request_steps: [
         put_user_agent: &Req.Steps.put_user_agent/1,
         compressed: &Req.Steps.compressed/1,
         encode_body: &Req.Steps.encode_body/1,
         put_base_url: &Req.Steps.put_base_url/1,
         auth: &Req.Steps.auth/1,
         put_params: &Req.Steps.put_params/1,
         put_path_params: &Req.Steps.put_path_params/1,
         put_range: &Req.Steps.put_range/1,
         cache: &Req.Steps.cache/1,
         put_plug: &Req.Steps.put_plug/1,
         compress_body: &Req.Steps.compress_body/1,
         checksum: &Req.Steps.checksum/1,
         put_aws_sigv4: &Req.Steps.put_aws_sigv4/1
       ],
       response_steps: [
         retry: &Req.Steps.retry/1,
         handle_http_errors: &Req.Steps.handle_http_errors/1,
         redirect: &Req.Steps.redirect/1,
         decompress_body: &Req.Steps.decompress_body/1,
         verify_checksum: &Req.Steps.verify_checksum/1,
         decode_body: &Req.Steps.decode_body/1,
         output: &Req.Steps.output/1
       ],
       error_steps: [retry: &Req.Steps.retry/1],
       private: %{}
     },
     %Req.Response{
       status: 404,
       headers: %{...},
       body: "",
       trailers: %{},
       private: %{}
     }}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions