Skip to content

fix: sql_analyze false 'unknown error' telemetry (AI-5975)#426

Merged
anandgupta42 merged 2 commits intomainfrom
fix/sql-analyze-false-failures
Mar 24, 2026
Merged

fix: sql_analyze false 'unknown error' telemetry (AI-5975)#426
anandgupta42 merged 2 commits intomainfrom
fix/sql-analyze-false-failures

Conversation

@kulvirgit
Copy link
Collaborator

@kulvirgit kulvirgit commented Mar 24, 2026

Summary

  • sql_analyze returned success: false when it found lint/semantic/safety issues, causing telemetry to log ~4,000 false "unknown error" core_failure events per day (AI-5975). Finding issues is a successful analysis — changed to success: true.
  • Real errors (parse failures, exceptions) now surface via metadata.error so telemetry captures the actual message instead of "unknown error".

Changes

File Change
packages/opencode/src/altimate/native/sql/register.ts success: issues.length === 0success: true
packages/opencode/src/altimate/tools/sql-analyze.ts Add metadata.error for real failures; fix title logic

Test plan

  • Typecheck clean (pre-existing tracing-viewer-e2e.test.ts error on main, unrelated)
  • Run sql_analyze on SQL with lint issues — should return success: true with issues listed
  • Run sql_analyze on unparseable SQL — should return success: false with metadata.error set

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved SQL analysis error detection and reporting
    • Parse errors are now more clearly surfaced with structured error information in results

…5975)

sql.analyze returned success:false when it found lint/semantic/safety
issues, causing telemetry to log ~4,000 false "unknown error" failures
per day. Finding issues IS a successful analysis.

- Change success flag to true when analysis completes without exceptions
- Surface actual error messages to metadata.error so telemetry can
  distinguish real failures from successful analyses

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 699e2514-2b35-4a57-8d76-c06a37b8d72c

📥 Commits

Reviewing files that changed from the base of the PR and between 528af75 and 99a5a86.

📒 Files selected for processing (2)
  • packages/opencode/src/altimate/native/sql/register.ts
  • packages/opencode/src/altimate/tools/sql-analyze.ts

📝 Walkthrough

Walkthrough

The PR refactors error handling in SQL analysis tools. The sql.analyze handler now always returns success: true unless an exception occurs, rather than deriving it from issue count. The sql-analyze tool now determines parse errors explicitly via result.error and surfaces error metadata more clearly in responses.

Changes

Cohort / File(s) Summary
Native SQL Handler
packages/opencode/src/altimate/native/sql/register.ts
Modified sql.analyze handler to always set success: true on successful execution, independent of issue count. Error handling via try/catch block remains unchanged.
SQL Analyze Tool
packages/opencode/src/altimate/tools/sql-analyze.ts
Changed "PARSE ERROR" title determination to check result.error instead of result.success. Enhanced error surfacing by conditionally including error field in response metadata and catch-block metadata.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Success no longer hinges on the count,
Errors now surface without a doubt,
With metadata clear, the path is bright,
SQL analysis flows more right! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly reflects the main change: fixing false telemetry alerts by correcting success field logic in sql_analyze.
Description check ✅ Passed The description includes a clear summary of the problem and solution, detailed changes, and a test plan with status indicators.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sql-analyze-false-failures

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants