dkataskin / erlazure

Windows Azure Erlang bindings
BSD 3-Clause "New" or "Revised" License
35 stars 53 forks source link

Uploading blob results in exception #25

Closed lukaleli closed 6 years ago

lukaleli commented 6 years ago

I have a super simple piece of code to upload file to my container called test:

defmodule Azure do
  def upload do
    account = "<SECRET_ACCOUNT_NAME>"

    key = "<SECRET_ACCOUNT_KEY>"

    {:ok, pid} = :erlazure.start(account, key)

    file = File.read!(Path.join([Path.expand("~/Downloads"), "srs.pdf"]))

    :erlazure.put_block_blob(
      pid,
      "test",
      "srs.pdf",
      file
    )
  end
end

When I run this in iex console it blows up and hangs the process with following stacktrace:

Interactive Elixir (1.7.0-dev) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Azure.upload
** (EXIT from #PID<0.144.0>) shell process exited with reason: an exception was raised:
    ** (FunctionClauseError) no function clause matching in :lists.thing_to_list/1
        (stdlib) lists.erl:603: :lists.thing_to_list("test")
        (stdlib) lists.erl:1250: :lists.flatmap/2
        (erlazure) /Users/lukaleli/Dev/azure/deps/erlazure/src/erlazure.erl:521: :erlazure.handle_call/3
        (stdlib) gen_server.erl:636: :gen_server.try_handle_call/4
        (stdlib) gen_server.erl:665: :gen_server.handle_msg/6
        (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

Interactive Elixir (1.7.0-dev) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>
18:54:32.344 [error] GenServer #PID<0.146.0> terminating
** (FunctionClauseError) no function clause matching in :lists.thing_to_list/1
    (stdlib) lists.erl:603: :lists.thing_to_list("test")
    (stdlib) lists.erl:1250: :lists.flatmap/2
    (erlazure) /Users/lukaleli/Dev/azure/deps/erlazure/src/erlazure.erl:521: :erlazure.handle_call/3
    (stdlib) gen_server.erl:636: :gen_server.try_handle_call/4
    (stdlib) gen_server.erl:665: :gen_server.handle_msg/6
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message (from #PID<0.144.0>): {:put_blob, "test", "srs.pdf", :block_blob, <<37, 80, 68, 70, 45, 49, 46, 51, 10, 37, 196, 229, 242, 229, 235, 167, 243, 160, 208, 196, 198, 10, 52, 32, 48, 32, 111, 98, 106, 10, 60, 60, 32, 47, 76, 101, 110, 103, 116, 104, 32, 53, 32, 48, 32, ...>>, []}
State: {:state, "<SECRET_ACCOUNT_NAME>", "<SECRET_ACCOUNT_KEY>", [], [blob_block_id: {:param_spec, :blob_block_id, :uri, 'blockid', #Function<10.30665059/1 in :erlazure_blob.get_request_param_specs/0>}, blob_content_length: {:param_spec, :blob_content_length, :header, 'x-ms-blob-content-length', #Function<14.30665059/1 in :erlazure_blob.get_request_param_specs/0>}, blob_copy_source: {:param_spec, :blob_copy_source, :header, 'x-ms-copy-source', #Function<13.30665059/1 in :erlazure_blob.get_request_param_specs/0>}, blob_range: {:param_spec, :blob_range, :header, 'Range', #Function<12.30665059/1 in :erlazure_blob.get_request_param_specs/0>}, blob_type: {:param_spec, :blob_type, :header, 'x-ms-blob-type', #Function<20.30665059/1 in :erlazure_blob.get_request_param_specs/0>}, block_list_type: {:param_spec, :block_list_type, :uri, 'blocklisttype', #Function<9.30665059/1 in :erlazure_blob.get_request_param_specs/0>}, comp: {:param_spec, :comp, :uri, 'comp', #Function<6.83802320/1 in :erlazure.get_req_common_param_specs/0>}, include: {:param_spec, :include, :uri, 'include', #Function<10.83802320/1 in :erlazure.get_req_common_param_specs/0>}, lease_action: {:param_spec, :lease_action, :header, 'x-ms-lease-action', #Function<19.30665059/1 in :erlazure_blob.get_request_param_specs/0>}, lease_break_period: {:param_spec, :lease_break_period, :header, 'x-ms-break-period', #Function<18.30665059/1 in :erlazure_blob.get_request_param_specs/0>}, lease_duration: {:param_spec, :lease_duration, :header, 'x-ms-lease-duration', #Function<17.30665059/1 in :erlazure_blob.get_request_param_specs/0>}, lease_id: {:param_spec, :lease_id, :header, 'x-ms-lease-id', #Function<16.30665059/1 in :erlazure_blob.get_request_param_specs/0>}, marker: {:param_spec, :marker, :uri, 'marker', #Function<11.83802320/1 in :erlazure.get_req_common_param_specs/0>}, max_results: {:param_spec, :max_results, :uri, 'maxresults', #Function<8.83802320/1 in :erlazure.get_req_common_param_specs/0>}, message_ttl: {:param_spec, :message_ttl, :uri, 'messagettl', #Function<9.5724061/1 in :erlazure_queue.get_request_param_specs/0>}, message_visibility_timeout: {:param_spec, :message_visibility_timeout, :uri, 'visibilitytimeout', #Function<10.5724061/1 in :erlazure_queue.get_request_param_specs/0>}, num_of_messages: {:param_spec, :num_of_messages, :uri, 'numofmessages', #Function<6.5724061/1 in :erlazure_queue.get_request_param_specs/0>}, peek_only: {:param_spec, :peek_only, :uri, 'peekonly', #Function<8.5724061/1 in :erlazure_queue.get_request_param_specs/0>}, pop_receipt: {:param_spec, :pop_receipt, :uri, 'popreceipt', #Function<7.5724061/1 in :erlazure_queue.get_request_param_specs/0>}, prefix: {:param_spec, :prefix, :uri, 'prefix', #Function<9.83802320/1 in :erlazure.get_req_common_param_specs/0>}, proposed_lease_id: {:param_spec, :proposed_lease_id, :header, 'x-ms-proposed-lease-id', #Function<15.30665059/1 in :erlazure_blob.get_request_param_specs/0>}, res_type: {:param_spec, :res_type, :uri, 'restype', #Function<11.30665059/1 in :erlazure_blob.get_request_param_specs/0>}, timeout: {:param_spec, :timeout, :uri, 'timeout', #Function<7.83802320/1 in :erlazure.get_req_common_param_specs/0>}]}
Client #PID<0.144.0> is alive
    (stdlib) gen.erl:169: :gen.do_call/4
    (stdlib) gen_server.erl:210: :gen_server.call/3
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
    (elixir) src/elixir.erl:233: :elixir.eval_forms/4
    (iex) lib/iex/evaluator.ex:245: IEx.Evaluator.handle_eval/5
    (iex) lib/iex/evaluator.ex:225: IEx.Evaluator.do_eval/3
    (iex) lib/iex/evaluator.ex:203: IEx.Evaluator.eval/3
    (iex) lib/iex/evaluator.ex:89: IEx.Evaluator.loop/1

Looks like genserver has no corresponding handler that matches calling pattern.

NOTE: I've checked if erlazure connects successfully to the Azure and it does. I was able to successfully list containers.

NOTE2: I'm using Elixir version 1.7.0-dev, but I'm not sure if it really affects that...

lukaleli commented 6 years ago

Geez, my bad. It's Erlang world, not Elixir. Strings are just nice Elixir feature. Erlang.expects charlists.

Issue can be closed now.