Files
openobserve/web/src/utils/templates
77aa943111 fix: creating shadow JSON, which will be responsible for validation (#8873)
### **User description**
resolves https://github.com/openobserve/openobserve/issues/8658


___

### **PR Type**
Bug fix, Enhancement


___

### **Description**
- Allow number placeholders in JSON templates

- Introduce shadow JSON validation logic

- Support quoted and bare placeholder replacements

- Improve import and create template validation


___

### Diagram Walkthrough


```mermaid
flowchart LR
  AddTemplate["AddTemplate.vue validation"] -- "build shadow JSON" --> JSONParse1["Parse testBody"]
  ImportTemplate["ImportTemplate.vue validation"] -- "build shadow JSON" --> JSONParse2["Parse testBody"]
  Placeholders["Placeholders {aaa}, {bbb}"] -- "quoted -> 'test'" --> AddTemplate
  Placeholders -- "bare value -> 0" --> ImportTemplate
```



<details> <summary><h3> File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Bug
fix</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>AddTemplate.vue</strong><dd><code>Shadow JSON
validation for template body</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></summary>
<hr>

web/src/components/alerts/AddTemplate.vue

<ul><li>Validate template body using shadow JSON.<br> <li> Replace
quoted placeholders with "test".<br> <li> Replace bare value
placeholders with 0.<br> <li> Preserve JSON.parse on transformed
body.</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8873/files#diff-2508a43827e6b35c07f3222deebd9945101ca6bc32b9dc592e6253ab99908bba">+12/-1</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>ImportTemplate.vue</strong><dd><code>Import validation
supports numeric placeholders</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

web/src/components/alerts/ImportTemplate.vue

<ul><li>Add shadow JSON logic during import validation.<br> <li> Replace
quoted placeholders with "test".<br> <li> Replace bare value
placeholders with 0.<br> <li> Provide clearer error on invalid
JSON.</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8873/files#diff-d22684c5142a49b8925a9dba1ef67631128caa95de66e71ba2a5b8120a0b91c6">+12/-1</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___

---------

Co-authored-by: sai nikhil kethe <nikhil@openobserve.ai>
Co-authored-by: Hengfei Yang <hengfei.yang@gmail.com>
2025-11-17 20:27:16 +05:30
..