(MatchError) no match of right hand side value: {:error, {:invalid, "T", 0}}


We’re getting (MatchError) no match of right hand side value: {:error, {:invalid, "T", 0}} quite randomly, haven’t been able to trace it down to specific issue - has anybody seen this?

Can you supply a full stack trace?

1 Like


    exception error: no match of right hand side value {error, {invalid,<<"T">>,0}}
      in function  'Elixir.CoinHunter.Fetchers.Orders':handle_info/2 (lib/coin_hunter/fetchers/orders.ex, line 31)
      in call from gen_server:try_dispatch/4 (gen_server.erl, line 616)
      in call from gen_server:handle_msg/6 (gen_server.erl, line 686)

Ok, can you show us the Elixir.CoinHunter.Fetchers.Orders':handle_info function?

1 Like

The easiest way to trace the bug, if you don’t provide us more info is:
use break if you have Elixir 1.5. Just run your server with iex -S mix phx.server.

The issues lies with the assignment that is in your function - you expect that result would be in specific format, but suddenly the one, you receive in that handle_info is different eg. {:ok, result} = Repo.insert(changeset) may throw you {:error, changeset}, so it will not match.

You can try to remove this pattern matching and log / debug what it’s the result.

Certainly more details would provide better answer from our side :wink:


Got it! The error was coming from Poison, the JSON parser, when it couldn’t parse the string. To see the string that caused the error, I’ve switched to exceptions for error handling, and also extended the default message to include the unparsable string:

  def parse!(json) do
    try do
      e in Poison.SyntaxError -> raise %{e | message: "#{e.message} (trying to parse \"#{json}\")"}

Thanks everybody for help!

1 Like

Awesome find, you should mark your own last post as solved (the 3-dots button then the checkmark in the square button). :slight_smile:

Looks like somebody already did it :slight_smile: Thanks for the pointer, I’ll keep it mind for the next time.