Skip to content

Invalid root_cause for mustache_exception #12292

@spalger

Description

@spalger

In the JavaScript tests I'm trying to validate the error output when specifying an invalid mustache template, and while the correct error is produced, it is not sent in the API response as the root cause.

@colings86 mentioned this is likely a bug in the exception XContent rendering. (whatever that means 😸)

Here is a trace of the request:

  -> POST http://localhost:9406/_render/template
  {
    "inline": "{ \"query\": { \"match\": { \"text\": \"{{{my_value}}\" } }, \"size\": {{my_size}} }",
    "params": {
      "my_value": "bar",
      "my_size": 100
    }
  }
  <- 500
  {
    "error": {
      "root_cause": [
        {
          "type": "script_exception",
          "reason": "Failed to compile inline script [{ \"query\": { \"match\": { \"text\": \"{{{my_value}}\" } }, \"size\": {{my_size}} }] using lang [mustache]"
        }
      ],
      "type": "script_exception",
      "reason": "Failed to compile inline script [{ \"query\": { \"match\": { \"text\": \"{{{my_value}}\" } }, \"size\": {{my_size}} }] using lang [mustache]",
      "caused_by": {
        "type": "mustache_exception",
        "reason": "Improperly closed variable in query-template:1"
      }
    },
    "status": 500
  }

And the test that produced it:

- do:
catch: /Improperly.closed.variable.in.query-template/
render_search_template:
body: { "inline": { "query": { "match": { "text": "{{{my_value}}" } }, "aggs": { "my_terms": { "terms": { "field": "{{my_field}}" } } } }, "params": { "my_value": "bar", "my_field": "field1" } }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions