Skip to content

Conversation

@ktx-abhay
Copy link
Collaborator

No description provided.

@github-actions github-actions bot added the ☢️ Bug Something isn't working label Sep 12, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Summary

This PR adds defensive programming to prevent runtime errors when handling streaming aggregation responses that contain empty hits arrays. The changes implement null/empty checks in three critical locations within the dashboard panel data loader:

  1. getDataThroughPartitions (line 557): Added a length check before spreading searchRes?.data?.hits into the state array
  2. handleHistogramResponse (line 667): Added a length check before spreading searchRes?.content?.results?.hits into the state
  3. handleStreamingHistogramHits (line 723): Added identical protection for streaming histogram hits

The pattern is consistent across all three locations: if (searchRes?.data?.hits?.length > 0) or similar, followed by the array spread operation only when data exists. This addresses a legitimate edge case where streaming aggregation APIs can return empty results during certain query phases or when no data matches the criteria.

These changes integrate well with the existing dashboard data loading architecture, which already handles asynchronous data fetching and state management. The defensive checks align with the codebase's approach to graceful error handling and prevent the UI from breaking when encountering empty result sets from backend streaming operations.

Confidence score: 4/5

  • This PR is safe to merge with minimal risk as it only adds protective checks without changing core logic
  • Score reflects defensive programming best practices and addresses a legitimate edge case in streaming data handling
  • No files require special attention as the changes are straightforward null checks

1 file reviewed, 2 comments

Edit Code Review Bot Settings | Greptile

@ktx-abhay ktx-abhay requested a review from omkarK06 September 12, 2025 07:28
@ktx-abhay ktx-abhay merged commit 864965f into branch-v0.14.6-rc9 Sep 12, 2025
47 of 49 checks passed
@ktx-abhay ktx-abhay deleted the fix/streaming-aggs-skip-empty-hits-rc9 branch September 12, 2025 09:42
ktx-abhay added a commit that referenced this pull request Sep 12, 2025
### **PR Type**
Bug fix


___

### **Description**
- Skip state updates for empty streaming hits

- Prevent overwriting data with empty arrays

- Apply fix across loader code paths


___

### Diagram Walkthrough


```mermaid
flowchart LR
  Source["searchRes (streaming_aggs)"] -- "hits length > 0 ?" --> Check["Check hits length"]
  Check -- "Yes" --> Update["Update state.data[currentQueryIndex]"]
  Check -- "No" --> Skip["Skip state update"]
```



<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>usePanelDataLoader.ts</strong><dd><code>Guard state
updates against empty streaming hits</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

web/src/composables/dashboard/usePanelDataLoader.ts

<ul><li>Guard assignments with hits length checks.<br> <li> Avoid
replacing state when hits are empty.<br> <li> Apply checks in three
streaming_aggs branches.</ul>


</details>


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

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

</details>

___

---------

Co-authored-by: omkark06 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

☢️ Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants