Skip to content

Conversation

@ktx-vaidehi
Copy link
Collaborator

No description provided.

@github-actions
Copy link
Contributor

Failed to generate code suggestions for PR

@testdino-playwright-reporter
Copy link

⚠️ Test Run Unstable


Author: ktx-vaidehi | Branch: feat/dashboard/custom-chart-support-for-promql | Commit: 5ba92ef

Testdino Test Results

Status Total Passed Failed Skipped Flaky Pass Rate Duration
All tests passed 365 345 0 19 1 95% 4m 39s

View Detailed Results

@testdino-playwright-reporter
Copy link

⚠️ Test Run Unstable


Author: ktx-vaidehi | Branch: feat/dashboard/custom-chart-support-for-promql | Commit: d4cca4c

Testdino Test Results

Status Total Passed Failed Skipped Flaky Pass Rate Duration
All tests passed 365 345 0 19 1 95% 4m 40s

View Detailed Results

@ktx-vaidehi ktx-vaidehi marked this pull request as ready for review October 28, 2025 11:32
@ktx-vaidehi ktx-vaidehi force-pushed the feat/dashboard/custom-chart-support-for-promql branch from d4cca4c to 7f17f9d Compare October 28, 2025 11:33
@github-actions
Copy link
Contributor

Failed to generate code suggestions for PR

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 Overview

Greptile Summary

This PR enables PromQL support for custom chart panels by modifying chart type validation, query type detection, and data structure handling across the dashboard panel system.

Key Changes

  • Chart Selection: Added custom_chart to the list of allowed chart types when in PromQL mode
  • Query Type Detection: Modified QueryTypeSelector to detect the actual queryType for custom charts instead of defaulting to custom-sql, enabling proper PromQL mode initialization
  • Query Preservation: When switching to PromQL mode, custom chart queries are now preserved instead of being cleared (non-custom charts still get reset to line charts)
  • Data Validation: Added custom_chart to the list of allowed chart types in panel validation logic
  • Data Structure Handling: Added conditional data structure checking in convertPanelData.ts to handle both PromQL (data[0].result) and SQL (data[0]) data formats

Issue Found

  • Missing optional chaining on PromQL data check in convertPanelData.ts:128 could cause runtime error if data[0] is undefined

Confidence Score: 4/5

  • Safe to merge after fixing the optional chaining issue in convertPanelData.ts
  • The implementation is sound and properly handles the addition of PromQL support for custom charts. The changes are well-targeted and preserve backwards compatibility. However, there's a missing optional chaining operator that could cause a runtime error in edge cases, which should be fixed before merging.
  • web/src/utils/dashboard/convertPanelData.ts - missing optional chaining on data[0].result check

Important Files Changed

File Analysis

Filename Score Overview
web/src/components/dashboards/addPanel/ChartSelection.vue 5/5 Added custom_chart to allowed chart types in PromQL mode
web/src/components/dashboards/addPanel/QueryTypeSelector.vue 5/5 Detects PromQL query type for custom charts and preserves query when switching to PromQL
web/src/utils/dashboard/convertDataIntoUnitValue.ts 5/5 Added custom_chart to allowed chart types in validation
web/src/utils/dashboard/convertPanelData.ts 4/5 Added PromQL data structure handling for custom charts; missing optional chaining on PromQL check

Sequence Diagram

sequenceDiagram
    participant User
    participant QueryTypeSelector
    participant ChartSelection
    participant PanelData
    participant convertPanelData
    participant CustomChart
    
    User->>QueryTypeSelector: Select PromQL mode
    QueryTypeSelector->>PanelData: Set queryType = "promql"
    QueryTypeSelector->>PanelData: Set customQuery = true
    
    alt Panel type is custom_chart
        QueryTypeSelector->>PanelData: Preserve existing query
    else Panel type is not custom_chart
        QueryTypeSelector->>PanelData: Clear query, set type = "line"
    end
    
    User->>ChartSelection: Select chart type
    Note over ChartSelection: custom_chart now allowed in PromQL mode
    ChartSelection->>PanelData: Update chart type
    
    User->>User: Execute query
    User->>convertPanelData: Process data
    
    alt queryType is promql
        convertPanelData->>convertPanelData: Check data[0].result.length
        convertPanelData->>CustomChart: Pass PromQL data structure
    else queryType is sql
        convertPanelData->>convertPanelData: Check data[0]?.length
        convertPanelData->>CustomChart: Pass SQL data structure
    end
    
    CustomChart->>User: Render custom chart
Loading

4 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines 126 to 129
const hasData =
panelSchema?.queryType === "promql"
? data.length > 0 && data[0].result.length > 0
: data.length > 0 && data[0]?.length > 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

syntax: potential issue with data structure check

The check data[0]?.length > 0 for SQL query type may not work correctly. Based on the codebase, SQL query data appears to be an array where data[0] is itself an array, so checking data[0]?.length > 0 is correct. However, for PromQL data, data[0].result is an array. The current check lacks optional chaining:

Suggested change
const hasData =
panelSchema?.queryType === "promql"
? data.length > 0 && data[0].result.length > 0
: data.length > 0 && data[0]?.length > 0;
const hasData =
panelSchema?.queryType === "promql"
? data.length > 0 && data[0]?.result?.length > 0
: data.length > 0 && data[0]?.length > 0;
Prompt To Fix With AI
This is a comment left during a code review.
Path: web/src/utils/dashboard/convertPanelData.ts
Line: 126:129

Comment:
**syntax:** potential issue with data structure check

The check `data[0]?.length > 0` for SQL query type may not work correctly. Based on the codebase, SQL query data appears to be an array where `data[0]` is itself an array, so checking `data[0]?.length > 0` is correct. However, for PromQL data, `data[0].result` is an array. The current check lacks optional chaining:

```suggestion
      const hasData =
        panelSchema?.queryType === "promql"
          ? data.length > 0 && data[0]?.result?.length > 0
          : data.length > 0 && data[0]?.length > 0;
```

How can I resolve this? If you propose a fix, please make it concise.

@testdino-playwright-reporter
Copy link

⚠️ Test Run Unstable


Author: ktx-vaidehi | Branch: feat/dashboard/custom-chart-support-for-promql | Commit: 7f17f9d

Testdino Test Results

Status Total Passed Failed Skipped Flaky Pass Rate Duration
1 test failed 366 345 1 19 1 94% 6m 53s

Test Failure Analysis

  1. dashboard-filter.spec.js: Timeout issues during page load and DOM stabilization
    1. dashboard filter testcases Should display an error message if added the invalid operator: Timeout waiting for page to reach 'networkidle' state.

Root Cause Analysis

  • The code changes in QueryTypeSelector.vue may have affected the timing of the page load, leading to the timeout error.

Recommended Actions

  1. Increase the timeout duration in the test to accommodate longer load times.
  2. Investigate the impact of recent changes in QueryTypeSelector.vue on the dashboard loading process.
  3. Add explicit waits for critical elements to ensure the page is fully loaded before proceeding.

View Detailed Results

@ktx-vaidehi ktx-vaidehi force-pushed the feat/dashboard/custom-chart-support-for-promql branch from 7f17f9d to 2e460e9 Compare October 28, 2025 12:16
@testdino-playwright-reporter
Copy link

⚠️ Test Run Unstable


Author: ktx-vaidehi | Branch: feat/dashboard/custom-chart-support-for-promql | Commit: 0812d07

Testdino Test Results

Status Total Passed Failed Skipped Flaky Pass Rate Duration
All tests passed 366 344 0 19 3 94% 4m 40s

View Detailed Results

@ktx-vaidehi ktx-vaidehi merged commit db46226 into main Oct 28, 2025
32 checks passed
@ktx-vaidehi ktx-vaidehi deleted the feat/dashboard/custom-chart-support-for-promql branch October 28, 2025 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants