Files
openobserve/tests
Abhay Padamani 664a05e75e fix: escape quote for variable values (#7134)
### **User description**
- Config to enable escape quotes. 

![image](https://github.com/user-attachments/assets/ad8fb954-a50a-447c-9ee2-f0938c3dcd16)

- Needs to enable it if variable value contains single quote.
For example variable value is `EFhoAf&fugy=P'fG;LR;Hr=jTe3fr).p%"`
then will require to escape single quote from value.

![image](https://github.com/user-attachments/assets/a05d983e-940a-4e3c-83c2-f7fd5206c4af)

- For custom typed variables, added some validations:
1. At least one option must there.
2. At lease one option should be selected as default value.


___

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


___

### **Description**
- Add `escapeSingleQuotes` flag to variable config

- Provide UI toggle with explanatory tooltip

- Update query loader to escape quotes conditionally

- Prevent removing last option and enforce default selection


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>mod.rs</strong><dd><code>Add escape_single_quotes field
to config</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

src/config/src/meta/dashboards/v5/mod.rs

<li>Introduce <code>escape_single_quotes</code> boolean field<br> <li>
Mark field as optional in <code>VariableList</code> struct


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/7134/files#diff-da49585bbcb02bf0f737bb68739ebc248edd15c7ad9427c0e68f7728bb4a8c17">+2/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>AddSettingVariable.vue</strong><dd><code>Enhance
variable settings UI for quote escaping</code>&nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

web/src/components/dashboards/settings/AddSettingVariable.vue

<li>Add <code>escapeSingleQuotes</code> toggle with tooltip<br> <li>
Initialize default <code>escapeSingleQuotes</code> value to false<br>
<li> Disable remove button when only one option remains<br> <li>
Validate at least one default selection for custom variables


</details>


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

</tr>

<tr>
  <td>
    <details>
<summary><strong>usePanelDataLoader.ts</strong><dd><code>Implement
conditional quote escaping in loader</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

web/src/composables/dashboard/usePanelDataLoader.ts

<li>Import <code>escapeSingleQuotes</code> utility<br> <li>
Conditionally escape single quotes in variable values<br> <li> Apply
escaping for both array and scalar values


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/7134/files#diff-5a42e9493a7bcd722b88e61fd38883c4f61001bc9cafa399f65f8eafda3aace9">+14/-2</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Documentation</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>en.json</strong><dd><code>Add translation for
escapeSingleQuotes</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

web/src/locales/languages/en.json

- Add `"escapeSingleQuotes": "Escape Single Quotes"` entry


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/7134/files#diff-892aa3d75ab6e129ef9116aa21bec1b9a15ba69ce5366d2a19128078c690d824">+1/-0</a>&nbsp;
&nbsp; &nbsp; </td>

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

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>
2025-06-11 22:21:55 +05:30
..
2024-09-22 17:57:47 +08:00