# ElasticsearchParseException: failed to parse search template [my_template]; error: Mustache runtime error at line 10: [{{#users}}] section has no closing tag

- **ID:** `elasticsearch/search-template-runtime-error`
- **Domain:** elasticsearch
- **Category:** config_error
- **Error Code:** `ES_SEARCH_TEMPLATE_PARSE_ERR`
- **Verification:** ai_generated
- **Fix Rate:** 86%

## Root Cause

A search template written in Mustache syntax has malformed tags (unclosed sections, mismatched delimiters, or nested errors) that prevent compilation.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.17.0 | active | — | — |
| 8.11.0 | active | — | — |
| 8.12.0 | active | — | — |

## Workarounds

1. **Validate the template using `POST _scripts/painless/_execute` or a Mustache linter to find unclosed sections. Fix by ensuring every `{{#section}}` has a corresponding `{{/section}}`.** (85% success)
   ```
   Validate the template using `POST _scripts/painless/_execute` or a Mustache linter to find unclosed sections. Fix by ensuring every `{{#section}}` has a corresponding `{{/section}}`.
   ```
2. **Simplify the template by breaking it into smaller parts and testing each with `GET /my_index/_search/template`.** (80% success)
   ```
   Simplify the template by breaking it into smaller parts and testing each with `GET /my_index/_search/template`.
   ```
3. **Use `POST _scripts/my_template` to update the template with corrected syntax, then test with `GET /_scripts/my_template`.** (90% success)
   ```
   Use `POST _scripts/my_template` to update the template with corrected syntax, then test with `GET /_scripts/my_template`.
   ```

## Dead Ends

- **** — Loses template dynamicity, requiring separate queries for each use case, increasing code complexity. (90% fail)
- **** — May create nested section errors if the section is already closed, leading to further parsing failures. (80% fail)
