Repository navigation
Conversation
…s at the row cap A traces read by literal trace id with no time bound probed every daily partition and ran past the 10s limit for large orgs. It now ANDs the same trace_index seek inspect_trace uses onto the trace-id conjunct, so it can only select rows the predicate already selects. Only SQL that passes the org-filter gate on its own is seeked, never a predicate inside if/NOT/OR or under an alias that shadows ServiceName or Timestamp; if the warehouse cannot analyse the seeked form, the query runs as written. A result over 1,000 rows failed after the query had already run. run_sql now wraps the statement in LIMIT 1000 and says it stopped at the cap; dashboard widgets and alerts keep the hard failure.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Maple review🟢 Confidence 8/10 · likely safe to merge
Findings🟠 Warning · F1 ·
|
| Change | Kind | Observable | Evidence |
|---|---|---|---|
| run_sql trace-id seek and fallback rerun | warehouse query path | yes | Both statements go through runRawSql → WarehouseQueryService.rawSqlQuery with context: "mcp.run_sql" (apps/ai/src/mcp/lib/run-raw-sql.ts:65), under the dispatcher's maple.mcp.tool span |
0c3d536 · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.
…ull page With the overflow row gone, a statement ending in LIMIT 1000 that returned 1,000 rows was told more rows may exist.
Maple review🟢 Confidence 10/10 · safe to merge
Fixed since the last review
What was checked
|
Maple review🟢 Confidence 9/10 · safe to merge
Findings🔵 Note · F2 · Seek pushes a near-limit statement past
|
| Change | Kind | Observable | Evidence |
|---|---|---|---|
| run_sql second warehouse run when the seeked form fails | outbound DB call | yes | goes through WarehouseQueryService.rawSqlQuery and recordRawSqlAudit (apps/ai/src/mcp/lib/run-raw-sql.ts:57) |
32224d9 · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.
A statement just under MAX_RAW_SQL_LENGTH passed the gate, then its seeked form was rejected as too long. The fallback test now asserts the seeked statement is issued first, so removing the seek fails it.
|
Both notes fixed in 6d4931f. F2: |
Maple review🟢 Confidence 10/10 · safe to merge
Fixed since the last review
What was checked
|
Maple review🟢 Confidence 8/10 · likely safe to merge Adds a trace_index seek to the tool's SQL when a trace-id filter has no time bound, and replaces the run_sql row-limit error with a capped result marked
Findings🟠 Warning · F4 ·
|
| Change | Kind | Observable | Evidence |
|---|---|---|---|
| run_sql fallback re-run of the unseeked statement | outbound warehouse query | yes | goes through the same instrumented executeRawSql / rawSqlQuery path as the first attempt |
33c8ed1 · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.
LIMIT 10, 5000 was read as a limit of 10, which hid the notice that the result stopped at the 1,000-row cap.
Maple review🟢 Confidence 10/10 · safe to merge run_sql now ANDs a trace_index seek onto unbounded TraceId predicates and truncates at the 1,000-row cap instead of failing, and the row-cap notice reads the count of
Fixed since the last review
What was checked
Observability coverage: 2 of 2 changes observable
|
Maple review🟢 Confidence 10/10 · safe to merge
Before merge
What was checked
Observability coverage: 1 of 1 changes observable
|
Maple review🟢 Confidence 10/10 · safe to merge Rewrites
Findings🔵 Note · F5 ·
|
| Change | Kind | Observable | Evidence |
|---|---|---|---|
| run_sql trace-id lookup (rewritten SQL) | warehouse query | yes | Still runs through runRawSql → WarehouseQueryService.rawSqlQuery on the existing traced raw-SQL path |
73e4b6b · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.
Maple review🟢 Confidence 10/10 · safe to merge
Fixed since the last review
What was checked
|
Two
run_sqlfailures where the work was wasted rather than the SQL wrong.What changed
traceswith a literalTraceId = '<id>'/TraceId IN (...)and no time bound probes every daily partition. In 14 days the 30 external lookups like this had a p95 of 11.2 s, against 1.07 s for the 500 bounded ones. On the internal agent, 30 of its 31 budget failures on trace lookups had no time filter.run_sqlnow ANDs onto that conjunct the sametrace_indexseek thatinspect_traceuses:(ServiceName, toStartOfFiveMinutes(Timestamp), TraceId) IN (SELECT ... FROM trace_index ...). Because it is ANDed onto the trace-id predicate itself, it can only select rows the predicate already selects.$__orgFilter);if(),NOTor an OR;ServiceName,TimestamporTraceId;run_sqlnow wraps the statement inLIMIT 1000, returns those rows, and says it stopped at the cap (atRowCap). Dashboard widgets and alerts keep the hard failure.How it was checked
trace_indexheld all 50 sampled traces at 1 hour, 20 days and 29 days old (the two tables share a 30-day TTL).trace-seek.test.ts: rewrite shape and every skip rule.run-sql-recovery.test.ts: the row cap, the issuedLIMIT 1000, and the fallback when the seeked form cannot be analysed.apps/aiandpackages/query-engine,vitestfor the query-engine runtime and theapps/aiMCP suites, andbun run lint:core.Stacked on #1959.
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.