Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FunctionClauseError: No function clause matching #39

Closed
travcunn opened this issue Aug 21, 2018 · 4 comments
Closed

FunctionClauseError: No function clause matching #39

travcunn opened this issue Aug 21, 2018 · 4 comments

Comments

@travcunn
Copy link

travcunn commented Aug 21, 2018

In one of our production systems, I am seeing the following in the logs hundreds of times. Should this exception be handled by the Elasticsearch Elixir client? The original function call is Elasticsearch.put_document.

(elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3

 ** (FunctionClauseError) no function clause matching in Elasticsearch.Exception.build/2

 (elasticsearch) lib/elasticsearch/exception.ex:35: Elasticsearch.Exception.build(%{"message" => nil}, nil)

 (elasticsearch) lib/elasticsearch/exception.ex:22: Elasticsearch.Exception.exception/1

 (elasticsearch) lib/elasticsearch.ex:389: Elasticsearch.format/1
@travcunn travcunn changed the title Error: No function clause matching FunctionClauseError: No function clause matching Aug 21, 2018
@danielberkompas
Copy link
Owner

Yes, this should be caught by the library. Do you know what the error payload Elasticsearch is returning looks like? I can see that it includes %{"message" => nil}, but wondered if there's any more detail in the Elasticsearch response than that.

@danielberkompas
Copy link
Owner

@travcunn it looks to me like you're not using the latest version of the library. lib/elasticsearch.ex:389 doesn't call Elasticsearch.format anymore. Have you tried upgrading to the latest version?

@travcunn
Copy link
Author

I found out why this was happening in our system. There was a loop that was calling Elasticsearch.put_document thousands of times. I would be interested in making an improvement to this project in such a way that unhandled errors just spit out raw HTTP errors so it is easier to debug Elasticsearch queries.

@ammbot
Copy link

ammbot commented Aug 29, 2018

I got the same error

Elixir.FunctionClauseError: no function clause matching in Elasticsearch.Exception.build/2
  File "lib/elasticsearch/exception.ex", line 35, in Elasticsearch.Exception.build/2
  File "lib/elasticsearch/exception.ex", line 22, in Elasticsearch.Exception.exception/1
  File "lib/elasticsearch.ex", line 389, in Elasticsearch.format/1

the argument to build/2 is
%{"message" => "Unable to connect to the server.", "ok" => false} and nil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants