Skip to content

ElasticSearch type-mangle fn causes type problems #98

@mbezjak

Description

@mbezjak

Logging java.lang.Exception and (java.lang.Throwable or java.lang.AssertionError) causes type problems (ironic? :)) due to the way type-mangle is implemented.

The relevant part of type-mangle (https://github.com/BrunoBonacci/mulog/blob/master/mulog-elasticsearch/src/com/brunobonacci/mulog/publishers/util.clj#L31):

(defn type-mangle
  [[k v :as e]]
  (cond
    ,,,
    (instance? Exception v) [(str k ".x") (ut/exception-stacktrace v)]
    :else e
    ))

This causes:

  1. Exception is mangled as equivalent of {"exception": {"x": "exception stack trace"}}
  2. Throwable is mangled as equivalent of {"exception": "exception stack trace"}

This doesn't work in ElasticSearch. "exception" must either be an object or a string.

ES HTTP error:

...
:status 400
:error {:type "mapper_parsing_exception"
        :reason "object mapping for [exception] tried to parse field [exception] as object, but found a concrete value"}
...

Suggestion

Change cond

(instance? Exception v) [(str k ".x") (ut/exception-stacktrace v)]

into

(instance? Throwable v) [(str k ".x") (ut/exception-stacktrace v)]

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions