fix: sql_pre_validation telemetry review followups#651
Conversation
Applies fixes from multi-model code review (Claude + GPT 5.4 + Gemini 3.1 Pro). Critical bugs (would corrupt shadow telemetry): - C1: validationResult.success was ignored — dispatcher failures with empty data evaluated as isValid=true, recording engine crashes as 'passed/valid'. Now checks .success first and emits outcome='error', reason='dispatcher_failed' on failure. - C2: database name was dropped from schema keys — multi-database warehouses collapsed DB1.PUBLIC.USERS and DB2.PUBLIC.USERS into one entry, and qualified queries got false-positive 'blocked' events. Keys now include database.schema.table; columns deduped per table to defend against residual collisions. Major fixes: - M1 (event-loop blocking): preValidateSql now yields via setImmediate before the synchronous bun:sqlite scan, so concurrent work isn't blocked while listColumns runs on large warehouses. - M2 (correlation fields): sql_pre_validation event now carries warehouse_type, query_type, and masked_sql_hash so shadow outcomes can be joined to sql_execute_failure events during analysis. - m5 (stale test list): sql_pre_validation added to ALL_EVENT_TYPES completeness check in telemetry.test.ts; count bumped 42 → 43. Minor fixes: - m3 (fragile matching): widened structural-error regex to include relation / identifier variants with word boundaries. - m4 (dead code): removed errorOutput construction — caller discards the result in shadow mode. Comment documents where to rebuild it when blocking mode is enabled.
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
📝 WalkthroughWalkthroughThis PR addresses critical correctness bugs in the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Follow-up from late Kimi K2.5 review: warehouses report view-not-found errors with 'view' keyword (e.g., 'View X does not exist'), which the regex previously missed — recorded as non_structural instead of blocked.
What does this PR do?
Follow-up to #643. Fixes review findings from multi-model consensus code review.
Critical bugs (would corrupt 2-week shadow telemetry data):
validationResult.successwas ignored. Dispatcher failures ({success: false, data: {}}) evaluated asisValid=true, recording engine crashes asoutcome="passed", reason="valid". Now checks.successfirst and emitsoutcome="error", reason="dispatcher_failed".databasename was dropped from schema context keys. Multi-database warehouses collapsedDB1.PUBLIC.USERSandDB2.PUBLIC.USERSinto one entry, and qualified queries got false-positiveblockedevents. Keys now usedatabase.schema.table; columns deduped per table to defend against residual collisions.Major fixes:
preValidateSqlnow yields viasetImmediatebefore the synchronousbun:sqlitescan, so concurrent work isn't blocked whilelistColumnsruns on large warehouses.sql_pre_validationevent now carrieswarehouse_type,query_type, andmasked_sql_hash(SHA-256 prefix of masked SQL). Shadow outcomes can be joined tosql_execute_failureevents per-warehouse / per-query-type.sql_pre_validationadded toALL_EVENT_TYPEScompleteness check intelemetry.test.ts; count bumped 42 → 43.Minor fixes:
relation|identifiervariants.errorOutputconstruction — caller discards it in shadow mode. Comment documents where to rebuild when blocking mode is enabled later.Type of change
Issue for this PR
Closes #650
How did you verify your code works?
ALL_EVENT_TYPESassertion)Checklist
Summary by cubic
Fixes critical bugs in SQL pre-validation telemetry and adds richer context so shadow data is accurate and easy to analyze. Also reduces event-loop blocking during schema scans.
Bug Fixes
database.schema.tablekeys and dedupe columns to avoid multi-database collisions.view/relation/identifier variants with word boundaries.New Features
warehouse_type,query_type, andmasked_sql_hashtosql_pre_validationevents for correlation withsql_execute_failure.setImmediatebefore the syncbun:sqlitescan to prevent event-loop blocking on large caches.sql_pre_validationto the event-type completeness test (count 42 → 43).Written for commit 4283169. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Chores