Skip to content

fix(console): preserve literal SQL in GitHub plan diffs - #6150

Merged
StuffbyYuki merged 1 commit into
SQLMesh:mainfrom
Vamsi-klu:codex/fix-5287-literal-plan-diffs
Nov 17, 2026
Merged

StuffbyYuki merged 1 commit into
SQLMesh:mainfrom
Vamsi-klu:codex/fix-5287-literal-plan-diffs

Conversation

@Vamsi-klu

@Vamsi-klu Vamsi-klu commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #5287.

Preserve literal SQL in GitHub plan-summary diffs, including T-SQL bracketed identifiers that Rich currently interprets as markup. A shared Markdown diff emitter captures the original text, prints it literally, and selects a fence longer than any embedded backtick sequence. It covers both model-diff emitters and environment SQL statements.

Regression coverage includes actual T-SQL models, tabs, long lines, markup-like literals, embedded fences, capture ordering, and the mocked final GitHub summary boundary.

Suggested reviewers: erindru, treysp.

Test Plan

  • python -m pytest tests/core/test_console.py tests/integrations/github/cicd/test_github_controller.py -q -n 0 -p no:rerunfailures: 63 passed.
  • python -m pytest tests/integrations/github/cicd/test_integration.py -k test_merge_pr_has_non_breaking_change -q -n 0 -p no:rerunfailures: 3 passed.
  • Reverting the production fix reproduces the regression failures; restoring it passes.
  • make style and make fast-test passed on this branch.

Checklist

  • I have run make style and fixed any issues
  • I have added tests for my changes (if applicable)
  • All existing tests pass (make fast-test)
  • My commits are signed off (git commit -s) per the DCO

Summary by CodeRabbit

  • Bug Fixes
    • SQL and other environment diffs are now displayed with appropriate Markdown formatting.
    • Diff output preserves literal text, including SQL identifiers and content containing backticks, and avoids including stale console output.
    • Model changes and categorized snapshot diffs now use consistent formatting in Markdown summaries.

@Vamsi-klu
Vamsi-klu marked this pull request as ready for review October 17, 2026 11:11
@StuffbyYuki

Copy link
Copy Markdown
Collaborator

Thanks for the PR! We'll take a look at this soon.

Apologies for our late response. Please keep in mind that you can ping us when you feel the PR needs immediate attention

@Vamsi-klu

Copy link
Copy Markdown
Contributor Author

Hi Yuki, while you are reviewing, quick side question: is there a way to get into the Tobiko community Slack without a @tobikodata.com address? I emailed hello@ a couple of days ago about it but have not heard back, and the signup page only takes company emails. Happy to be invited by email if that is the path. Thanks!

@StuffbyYuki

Copy link
Copy Markdown
Collaborator

@Vamsi-klu You don't need a tobiko email address. Anyone can join the slack channel!

@Vamsi-klu

Copy link
Copy Markdown
Contributor Author

@StuffbyYuki so, when I tried using the link provided in the docs, Slack is not letting me join because I don't have the company email address. Is there a better solution or any different link that you could help me provide? Happy to be part of the group.

@StuffbyYuki

Copy link
Copy Markdown
Collaborator

Okay let me look into it. Something might've changed

@StuffbyYuki

StuffbyYuki commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Try this link for now to see if it works

Signed-off-by: Vamsi-klu <nrvamsi13@gmail.com>
@StuffbyYuki
StuffbyYuki force-pushed the codex/fix-5287-literal-plan-diffs branch from ce289dc to b1881ee Compare November 17, 2026 04:24
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Markdown console diff output now uses dynamically sized code fences and routes SQL environment statements, modified-model diffs, and categorized-snapshot diffs through a shared helper. Tests cover console output and GitHub CI/CD plan summaries.

Changes: Markdown Diff Rendering

Layer / File(s) Summary
Render and validate Markdown diffs
sqlmesh/core/console.py, tests/core/test_console.py, tests/integrations/github/cicd/test_github_controller.py
MarkdownConsole._print_diff selects a backtick fence longer than any run in the diff, indents and captures the Markdown block, and prints it with markup and emoji processing disabled. SQL environment statements, modified-model diffs, and categorized-snapshot diffs use the helper. Tests cover literal content, output ordering and capture, and plan-summary output.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Suggested reviewers: cmgoffena13, mday-io

Merge Risk: Minimal · up to b1881

This change makes GitHub plan-summary diffs show SQL literally, including bracketed T-SQL identifiers, and uses longer code fences when the diff itself contains backticks. The change is narrowly scoped to Markdown output and comes with regression tests. No actionable merge risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: it fixes the console so literal SQL is preserved in GitHub plan diffs. The changeset adds a shared Markdown diff emitter in sqlmesh/core/console.py, updates environmen…
Description check Passed The description follows the template. It has a Description section that explains the fix and links issue #5287. It has a Test Plan section that lists the commands run and their results. It has a Check…
Linked Issues check Passed Issue #5287 reports that CI/CD bot plan diffs render differently from CLI output. The issue sets no explicit acceptance criteria. The implied coding requirement is that GitHub plan-summary diffs show …
Out of Scope Changes check Passed All changes in the reviewed diff relate to the linked issue. sqlmesh/core/console.py adds the re import, the _print_diff helper, and call-site updates for SQL environment statements, modified-model di…
Full details: Title check

Explanation

The title names the main change: it fixes the console so literal SQL is preserved in GitHub plan diffs. The changeset adds a shared Markdown diff emitter in sqlmesh/core/console.py, updates environment SQL and model-diff output, and adds tests for literal SQL in the GitHub controller. The title is concise, specific, and follows the conventional-commit style.

Full details: Description check

Explanation

The description follows the template. It has a Description section that explains the fix and links issue #5287. It has a Test Plan section that lists the commands run and their results. It has a Checklist with the required items marked. The description adds suggested reviewers and extra regression coverage details, which go beyond the template but do not conflict with it.

Full details: Linked Issues check

Explanation

Issue #5287 reports that CI/CD bot plan diffs render differently from CLI output. The issue sets no explicit acceptance criteria. The implied coding requirement is that GitHub plan-summary diffs show the original text, including bracketed T-SQL identifiers that Rich treats as markup. The reviewed diff of sqlmesh/core/console.py addresses this. The new MarkdownConsole._print_diff helper prints diff blocks with markup=False and emoji=False, and captures the Markdown source. It selects a fence longer than any backtick run in the diff. Modified-model diffs and categorized-snapshot diffs now call _print_diff. Environment SQL statements (language == "sql") also route through _print_diff. The PR summary reports regression tests for T-SQL models, markup-like literals, embedded fences, and the GitHub summary boundary. I did not read the test file diff. The remaining uncertainty is whether every model-diff emitter is covered. The summary names only the emitters changed in the diff, and the diff matches that list.

Full details: Out of Scope Changes check

Explanation

All changes in the reviewed diff relate to the linked issue. sqlmesh/core/console.py adds the re import, the _print_diff helper, and call-site updates for SQL environment statements, modified-model diffs, and categorized-snapshot diffs. These updates implement the literal, fence-safe diff output. Test changes in tests/core/test_console.py and tests/integrations/github/cicd/test_github_controller.py cover this behavior and support the fix. No unrelated behavior change appeared in the inspected diff. One minor formatting side effect exists. The categorized-snapshot path now emits a leading newline from the helper, but this does not change the content and is part of the same output path.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3f17ad6b-16c1-4b68-8ccf-9112b7f485cb
Commits

Reviewing files that changed from the base of the PR and between 3df452c and b1881ee.

Files selected for processing: 3

  • sqlmesh/core/console.py
  • tests/core/test_console.py
  • tests/integrations/github/cicd/test_github_controller.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@StuffbyYuki
StuffbyYuki merged commit 220ef31 into SQLMesh:main Nov 17, 2026
36 checks passed
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.

[CI/CD bot] Some plan diff output incompatible with GitHub markdown

2 participants