Skip to content

fix: Prevent various invalid DESCRIBE queries#2448

Open
pulpdrew wants to merge 2 commits into
mainfrom
drew/skip-empty-where-render
Open

fix: Prevent various invalid DESCRIBE queries#2448
pulpdrew wants to merge 2 commits into
mainfrom
drew/skip-empty-where-render

Conversation

@pulpdrew

@pulpdrew pulpdrew commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds some conditions that prevent a few invalid DESCRIBE queries, which resulted in console errors:

  1. Prevent calling renderWhereExpression for an empty aggCondition on a select item. This fixes the invalid DESCRIBE queries mentioned in Grouped metric charts/alerts emit a failing DESCRIBE TABLE .Bucketed (UNKNOWN_TABLE) on every evaluation #2409
  2. Prevent Lucene --> English translation when the table/database/connection is not provided. These will error, and are typically due to the sources not being loaded yet (they happen on page load)

Screenshots or video

Before - Invalid DESCRIBE .Bucket and DESCRIBE . queries being issued from renderWhereExpression and Lucene --> English translation:

Screenshot 2026-06-11 at 11 53 24 AM

After - No such invalid queries:

Screenshot 2026-06-11 at 11 49 14 AM

How to test on Vercel preview

  • Create a chart that targets a metric. Add a where condition and optionally a group by.
  • Run the query, reload the page, and check the console logs or network tab for invalid describe queries

References

@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hyperdx-oss Ready Ready Preview, Comment Jun 12, 2026 1:57pm
hyperdx-storybook Ready Ready Preview, Comment Jun 12, 2026 1:57pm

Request Review

@changeset-bot

changeset-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d7d4bf3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hyperdx/common-utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Jun 11, 2026
@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 2
  • Production lines changed: 28 (+ 60 in test files, excluded from tier calculation)
  • Branch: drew/skip-empty-where-render
  • Author: pulpdrew

To override this classification, remove the review/tier-2 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@pulpdrew pulpdrew changed the title fix: Skip rendering empty aggConditions fix: Prevent various invalid DESCRIBE queries Jun 11, 2026
@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds two guards to prevent invalid DESCRIBE queries that were causing console errors: one in renderSelectList to skip renderWhereExpression when aggCondition is empty, and one in genEnglishExplanation to skip Lucene→English translation when tableName, databaseName, or connectionId are missing.

  • renderChartConfig.ts: Wraps the renderWhereExpression call for aggCondition with isNonEmptyWhereExpr; falls back to chSql`` (empty where), which aggFnExpralready handles correctly via its ownisNonEmptyWhereExpr` check on line 499.
  • queryParser.ts: Extends the parsedQ truthy check to also require all three connection fields, returning the "Message containing …" fallback instead of firing a doomed DESCRIBE query on page load before sources are initialized.
  • Tests: New genEnglishExplanation test suite validates the happy path and all three individual missing-field fallback cases.

Confidence Score: 5/5

Safe to merge — both fixes are defensive early-exit guards with no effect on code paths where the conditions are already satisfied.

The changes are minimal, well-tested, and touch only the two call sites that were producing spurious DESCRIBE queries. The empty-where fallback feeds into existing isNonEmptyWhereExpr handling inside aggFnExpr, so behavior for non-empty conditions is unchanged.

No files require special attention.

Important Files Changed

Filename Overview
packages/common-utils/src/core/renderChartConfig.ts Guards renderWhereExpression call with isNonEmptyWhereExpr check to prevent invalid DESCRIBE queries for empty aggCondition; falls back to chSql`` which correctly produces an empty where string for aggFnExpr.
packages/common-utils/src/queryParser.ts Adds tableName/databaseName/connectionId presence check before constructing EnglishSerializer, preventing invalid DESCRIBE queries during page load before sources are ready.
packages/common-utils/src/tests/queryParser.test.ts New test suite for genEnglishExplanation covering the happy path and all three missing-field fallback scenarios; good coverage of the new guard.
.changeset/fuzzy-knives-bathe.md New patch changeset for @hyperdx/common-utils; description only mentions the aggCondition fix (second fix for Lucene translation omitted).

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[renderSelectList] --> B{isNonEmptyWhereExpr\naggCondition?}
    B -- yes --> C[renderWhereExpression\nDESCRIBE query fires]
    B -- no --> D[chSql empty\nno DESCRIBE]
    C --> E[aggFnExpr\nwhere = whereClause.sql]
    D --> E

    F[genEnglishExplanation] --> G{parsedQ &&\ntableName &&\ndatabaseName &&\nconnectionId?}
    G -- yes --> H[EnglishSerializer\nDESCRIBE query fires]
    G -- no --> I[fallback:\nMessage containing query]
    H --> J[return English text]
    I --> J
Loading

Reviews (3): Last reviewed commit: "fix: Skip english lucene generation when..." | Re-trigger Greptile

Comment thread packages/common-utils/src/core/renderChartConfig.ts
Comment thread .changeset/fuzzy-knives-bathe.md
@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

E2E Test Results

All tests passed • 202 passed • 3 skipped • 1307s

Status Count
✅ Passed 202
❌ Failed 0
⚠️ Flaky 1
⏭️ Skipped 3

Tests ran across 4 shards in parallel.

View full report →

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grouped metric charts/alerts emit a failing DESCRIBE TABLE .Bucketed (UNKNOWN_TABLE) on every evaluation

1 participant