[superlog] Log SQL tool query failures as WARN instead of ERROR#500
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
The latest updates on your projects. Learn more about Unkey Deploy
|
|
Tracking note from the Superlog PR pass: this is the clean one-file version of the SQL tool query failure log-level fix, and it appears to supersede the conflict-heavy staging PR #497. I am not merging it while it targets |
izadoesdev
left a comment
There was a problem hiding this comment.
Retargeted this from main to staging and verified the diff remains the intended one-line change in executeTimedQuery: failed SQL tool queries now log at WARN while still rethrowing. This complements the already-merged request-scoped tool logging cleanup and supersedes the conflict-heavy #497 path. Verification: cd packages/ai && bun run check-types, bun run lint, bun run check-types, and root bun run test all pass. Note: a direct cd packages/ai && bun run test invocation does not load the root dotenv env and fails unrelated tests on missing REDIS_URL/DATABASE_URL; the repo-standard root test path passes.
Summary
Insights generation jobs that succeed are being logged at ERROR severity, creating false-positive incidents. Both sampled occurrences show
job_status: "succeeded"andrun_status: "succeeded"alongsidelevel: "error"— the jobs completed and produced insights.The insights service wires the AI package's tool logger to the insights job's wide-event logger (
RequestLogger). WhenexecuteTimedQuerycatches a ClickHouse query failure inside theexecute_sqlAI tool, it callsrequestLogger.error()on the job logger. In evlog, this permanently upgrades the wide event's severity to ERROR. Even though the AI agent recovers from the query failure and completes successfully, the finallogger.emit({ job_status: "succeeded" })fires at ERROR level.The fix changes
logger.error()tologger.warn()for SQL query failures inexecuteTimedQuery. Tool-level query failures are recoverable — the AI agent catches the error and can try a different approach or proceed — so WARN is the correct severity. All diagnostic fields (SQL, execution time, error message) remain captured. Jobs that actually fail at the job level (thrown errors inprocessInsightsJob) continue to emit at ERROR via the explicitlogger.error(err)call in the failure path.Alternative: a per-context severity override could be added to
createToolLoggerso API and insights contexts can configure tool failure severity independently. This one-line change is the most targeted fix with the least blast radius.Incident on Superlog
Was this PR helpful? Leave feedback — goes straight to the Superlog team.
Summary by cubic
Downgraded SQL tool query failures from ERROR to WARN in
executeTimedQueryto prevent false-positive incidents on successful insight jobs. Diagnostics are unchanged; real job failures still log as ERROR.logger.error("Query failed", ...)tologger.warn(...)inpackages/ai/src/ai/tools/utils/query.ts, avoiding job-wide ERROR severity when the agent recovers.Written for commit 97cc2a6. Summary will update on new commits.