Skip to content

fix mcp and query normalization - #257

Merged
dbulashev merged 1 commit into
mainfrom
fix-pgss-normalization
Aug 30, 2026
Merged

fix mcp and query normalization#257
dbulashev merged 1 commit into
mainfrom
fix-pgss-normalization

Conversation

@dbulashev

@dbulashev dbulashev commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Query reports can now include a specific query even when it does not rank among the top metrics.
    • Improved SQL handling restores supported parameter casts, enabling parsing, fingerprinting, and index analysis for more query formats.
  • Documentation

    • Clarified how to retrieve full statement text, use query IDs, and interpret truncated query displays.
    • Documented statement-length limits and improved index-advisor guidance.

@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c0f6875f-1428-4f17-b319-f51b8c10acbb

📥 Commits

Reviewing files that changed from the base of the PR and between 8d09280 and 895577a.

📒 Files selected for processing (7)
  • backend/internal/mcpserver/client.go
  • backend/internal/mcpserver/kb/en/index-advisor.md
  • backend/internal/mcpserver/kb/ru/index-advisor.md
  • backend/internal/mcpserver/tools.go
  • backend/internal/sqlparse/paramcast.go
  • backend/internal/sqlparse/paramcast_test.go
  • backend/internal/sqlparse/parser.go

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The MCP query report flow now accepts explicit query IDs. The SQL parser restores supported typed parameter casts before retrying parse and fingerprint operations. Tests cover rewrite behavior, parser acceptance, idempotence, and column usage.

Changes

MCP query reporting

Layer / File(s) Summary
Query report query ID wiring
backend/internal/mcpserver/client.go, backend/internal/mcpserver/tools.go, backend/internal/mcpserver/kb/*/index-advisor.md
The query_report tool accepts and forwards queryid. The client includes it in GetQueriesReport. Tool descriptions and English and Russian guidance describe full query text, truncation, and query ID behavior.

SQL parameter restoration

Layer / File(s) Summary
Typed parameter cast restoration
backend/internal/sqlparse/paramcast.go, backend/internal/sqlparse/paramcast_test.go
RestoreParamCasts rewrites supported typed and interval parameter forms. Tests cover valid SQL preservation, idempotence, type variants, and interval forms.
Parser and fingerprint retry integration
backend/internal/sqlparse/parser.go, backend/internal/sqlparse/paramcast_test.go
parseUncached and Fingerprint retry with restored SQL after an initial failure. Tests verify parsing, fingerprinting, and column usage.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: 🔵 Low · up to 89557

The PR adds query selection by ID through the existing authorization path and improves parsing of normalized SQL. It is mergeable with owner awareness that fallback normalization can expand input beyond the configured parser size limit, creating a bounded availability risk during analysis.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant query_report_tool
  participant DashaClient
  participant GetQueriesReport
  Caller->>query_report_tool: Submit queryid and report arguments
  query_report_tool->>DashaClient: Call QueryReport with queryID
  DashaClient->>GetQueriesReport: Send Queryid with report parameters
  GetQueriesReport-->>DashaClient: Return the matching report row
  DashaClient-->>query_report_tool: Return query report
  query_report_tool-->>Caller: Return full query details
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 5 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately identifies both main change areas: MCP updates and query normalization. It is concise and related to the changeset, although it is somewhat broad.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 5 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-pgss-normalization

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.

@dbulashev

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@dbulashev
dbulashev merged commit 1d73298 into main Aug 30, 2026
20 checks passed
@dbulashev
dbulashev deleted the fix-pgss-normalization branch August 30, 2026 09:51
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.

1 participant