Skip to content

Revert "fix: unknown lucene field falls through in search" - #2447

Merged
kodiakhq[bot] merged 3 commits into
mainfrom
revert-2422-lucene-unknown-field-falls-through-as-a-raw-sql-identifier
Jun 12, 2026
Merged

Revert "fix: unknown lucene field falls through in search"#2447
kodiakhq[bot] merged 3 commits into
mainfrom
revert-2422-lucene-unknown-field-falls-through-as-a-raw-sql-identifier

Conversation

@karl-power

Copy link
Copy Markdown
Contributor

Reverts #2422

@changeset-bot

changeset-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f2dc0b7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@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 8:56am
hyperdx-storybook Ready Ready Preview, Comment Jun 12, 2026 8:56am

Request Review

@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: 105 (+ 440 in test files, excluded from tier calculation)
  • Branch: revert-2422-lucene-unknown-field-falls-through-as-a-raw-sql-identifier
  • Author: karl-power

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

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

E2E Test Results

All tests passed • 199 passed • 3 skipped • 1326s

Status Count
✅ Passed 199
❌ Failed 0
⚠️ Flaky 4
⏭️ Skipped 3

Tests ran across 4 shards in parallel.

View full report →

@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR reverts #2422 ("fix: unknown lucene field falls through in search"), removing the SELECT-alias resolution feature (extractSelectAliases, selectAliases wiring across renderWhere/renderHaving/renderSelectList) and all associated tests. Two regressions from the pre-#2422 state are reintroduced.

  • Null dereference on materializedColumns: The ?? new Map() guard is gone; if getMaterializedColumnsLookupTable resolves to null (as the base mockMetadata in renderChartConfig.test.ts does at line 40), materializedColumns.entries() will throw a TypeError outside the surrounding try/catch.
  • Unknown Lucene fields pass through as raw SQL: The fallback now returns { found: true, columnExpression: field } for any field that is neither a known column nor a prefix match, causing ClickHouse to reject the query with an "Unknown identifier" error for typos or non-existent fields (the // TODO: Verify aliases comment acknowledges this is intentionally temporary).

Confidence Score: 3/5

The revert reintroduces two broken behaviors: a null-dereference crash in the exact-match path and raw-SQL injection of unrecognized Lucene field names into ClickHouse queries.

Removing the ?? new Map() guard means any metadata implementation returning null from getMaterializedColumnsLookupTable will crash with a TypeError at materializedColumns.entries(), outside the try/catch. The fallback returning { found: true } for unknown fields means ClickHouse will receive raw, unvalidated identifiers and reject the query at runtime.

Both queryParser.ts (null guard removal and unknown-field fallback) and renderChartConfig.ts (alias wiring removal) warrant a close look before merging.

Important Files Changed

Filename Overview
packages/common-utils/src/queryParser.ts Removes selectAliases plumbing and reverts the unknown-field fallback from found: false to found: true with a bare identifier; also removes the ?? new Map() null guard on getMaterializedColumnsLookupTable, which can cause a TypeError when the lookup resolves to null.
packages/common-utils/src/core/renderChartConfig.ts Removes extractSelectAliases helper and all selectAliases forwarding to renderWhereExpressionStr across WHERE, HAVING, filters, and per-aggregate conditions; removes chSqlToAliasMap import.
packages/common-utils/src/tests/queryParser.test.ts Removes the bar column mock and the CustomSchemaSQLSerializerV2: select alias resolution test suite.
packages/common-utils/src/tests/renderChartConfig.test.ts Removes severity column from test fixture and deletes two large test suites covering SELECT alias resolution in WHERE, filters, per-aggregate conditions, HAVING, string-form selects, and expression-form WITH clauses.
.changeset/healthy-pans-grab.md Deletes the changeset entry for the patch that is being reverted.

Reviews (3): Last reviewed commit: "Merge branch 'main' into revert-2422-luc..." | Re-trigger Greptile

Comment on lines 1477 to +1482
materializedColumns =
(await this.metadata.getMaterializedColumnsLookupTable({
await this.metadata.getMaterializedColumnsLookupTable({
databaseName: this.databaseName,
tableName: this.tableName,
connectionId: this.connectionId,
})) ?? new Map();
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 The ?? new Map() null-coalescing guard was intentionally added in #2422 to defend against getMaterializedColumnsLookupTable resolving to null or undefined. Without it, if the call resolves to null (e.g. some Metadata implementations or test mocks use mockResolvedValue(null)), materializedColumns.entries() will throw a TypeError outside the try/catch block — the catch only covers the await, not the iteration below it. The base mockMetadata in renderChartConfig.test.ts (line 40) still mocks this to return null, so any test that reaches this exact-match path with the default mock will now fail.

Suggested change
materializedColumns =
(await this.metadata.getMaterializedColumnsLookupTable({
await this.metadata.getMaterializedColumnsLookupTable({
databaseName: this.databaseName,
tableName: this.tableName,
connectionId: this.connectionId,
})) ?? new Map();
});
materializedColumns =
(await this.metadata.getMaterializedColumnsLookupTable({
databaseName: this.databaseName,
tableName: this.tableName,
connectionId: this.connectionId,
})) ?? new Map();

Fix in Claude Code Fix in Conductor Fix in Cursor Fix in Codex

Comment on lines +1589 to +1596
// It might be an alias, let's just try the column
// TODO: Verify aliases
return {
found: false,
found: true,
columnExpression: field,
columnType: 'Unknown',
};
// throw new Error(`Column not found: ${field}`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Unknown fields now always pass through as bare identifiers

The fallback now returns { found: true, columnExpression: field } for any field that is not a known column or prefix match, and the original throw is left commented out. This means an unrecognised Lucene field name (e.g. a typo) is injected as a raw SQL identifier, which ClickHouse will reject with an "Unknown identifier" error at query time instead of returning a clean no-match result. The // TODO: Verify aliases comment signals this is a known temporary state — worth tracking the replacement work so users don't get opaque ClickHouse errors on invalid field references.

Fix in Claude Code Fix in Conductor Fix in Cursor Fix in Codex

@kodiakhq
kodiakhq Bot merged commit e1b4769 into main Jun 12, 2026
19 checks passed
@kodiakhq
kodiakhq Bot deleted the revert-2422-lucene-unknown-field-falls-through-as-a-raw-sql-identifier branch June 12, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants