René's URL Explorer Experiment


Title: feat: skip state-sync for the `format` command by j-hartshorn · Pull Request #5804 · SQLMesh/sqlmesh · GitHub

Open Graph Title: feat: skip state-sync for the `format` command by j-hartshorn · Pull Request #5804 · SQLMesh/sqlmesh

X Title: feat: skip state-sync for the `format` command by j-hartshorn · Pull Request #5804 · SQLMesh/sqlmesh

Description: Description sqlmesh format previously required a reachable state-sync backend on every invocation, because Context.load() unconditionally merges remote-prod state into the local model registry whenever a config declares a project: name. That made the command unrunnable in CI jobs that have no credentials or network access to the state backend, even though formatting is a pure local operation - it parses each local file and re-prints the AST, never resolving references. This PR adds a load_state: bool = True parameter to GenericContext that gates the two if any(self._projects): state-merge blocks in Context.load(), and adds a LOCAL_ONLY_COMMANDS = ("format",) tuple in sqlmesh/cli/main.py that flips it to False for that subcommand. The default behaviour for every other command (plan, run, lint, diff, etc.) is unchanged. Scope note: this PR originally covered lint as well, but was narrowed after review (see discussion below). In multi-repo projects, lint results depend on models merged from prod state at load time - models owned by other repos aren't on disk, and skipping the merge flipped lint from pass to fail even with state credentials available (reproduced with examples/multi, where repo_2's silver.c selects from repo_1's bronze.a). lint therefore still loads state, locked in by a guard test, and the lint case in #5182 remains open. Verified end-to-end with a real config.yaml declaring a Postgres state connection via {{ env_var() }} with no env vars set: pre-PR, sqlmesh format exits 1 with psycopg2.OperationalError: could not translate host name. Post-PR, exit 0. One known caveat: Snowflake state connections under default authentication validate user/password at config-load time via SnowflakeConnectionConfig._validate_authenticator (sqlmesh/core/config/connection.py:633-638), which runs before this PR's gate. That pre-existing validator means a Snowflake-default-auth state config still requires placeholder user/password values to be set. Postgres, MySQL, MSSQL, and the other backends pass validation with placeholder values. Test Plan Seven tests across two files: tests/core/test_format.py::test_format_without_state_load (fast) - context.format(check=True) with load_state=False and a patched EngineAdapterStateSync.get_versions that raises. Asserts the patched method is never called. tests/cli/test_cli.py::test_format_runs_without_state (slow) - end-to-end via the CLI runner. tests/cli/test_cli.py::test_local_only_commands_skip_state_multiple_paths (slow) - same, invoked with two --paths, locking in that the gate applies regardless of invocation shape. tests/cli/test_cli.py::test_format_runs_without_state_multi_repo_partial (slow) - formats one repo of examples/multi whose upstream models live only in prod state; the shape that motivated narrowing the PR. tests/cli/test_cli.py::test_lint_still_loads_state (slow) - guard-rail for the narrowing. Spies on Context.__init__, asserts load_state=True is explicitly passed for lint, and asserts state sync is actually reached. tests/cli/test_cli.py::test_plan_still_loads_state (slow) - same guard for plan. Both verified non-vacuous by regression modes (deleting the kwarg from cli/main.py, and re-adding the command to LOCAL_ONLY_COMMANDS). tests/cli/test_cli.py::test_format_does_not_open_state_connection (slow) - most realistic CI scenario: a config.yaml declaring a Postgres state connection via {{ env_var() }} with all env vars unset. Verifies the gate prevents the connection. Commands run: make py-style - clean (ruff, ruff-format, mypy, valid migrations). Full test selection above - all passing.

Open Graph Description: Description sqlmesh format previously required a reachable state-sync backend on every invocation, because Context.load() unconditionally merges remote-prod state into the local model registry when...

X Description: Description sqlmesh format previously required a reachable state-sync backend on every invocation, because Context.load() unconditionally merges remote-prod state into the local model registry when...

Opengraph URL: https://github.com/SQLMesh/sqlmesh/pull/5804

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/commits/:range(.:format)
route-controllerpull_requests
route-actioncommits
fetch-noncev2:96596eab-5740-bb8e-e4ff-295d73227151
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD672:352D9:4C74A85:66730AF:6A655A7F
html-safe-nonce7b59cbe9b0b67c9c3a5e8df1343bee582b362c59d89edc65b90b293de6352b0a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENjcyOjM1MkQ5OjRDNzRBODU6NjY3MzBBRjo2QTY1NUE3RiIsInZpc2l0b3JfaWQiOiI2ODIyOTc5MzYxNjczOTI3Mjk1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac4975254b9d643e661e9e9c214cf8e06cb2169b4d452bfb40cfea8cc5830342b3
hovercard-subject-tagpull_request:3723451560
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/commits
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/SQLMesh/sqlmesh/pull/5804/commits/4ee6662a58f5e632aab2bb0acb1dd62328bd0f67
twitter:imagehttps://avatars.githubusercontent.com/u/8881940?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/8881940?s=400&v=4
og:image:altDescription sqlmesh format previously required a reachable state-sync backend on every invocation, because Context.load() unconditionally merges remote-prod state into the local model registry when...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None52c76df668885aaff23b50bdca1fa1ea44ac9c1553e888ebc70ff1e4daa4625b
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/SQLMesh/sqlmesh git https://github.com/SQLMesh/sqlmesh.git
octolytics-dimension-user_id265658263
octolytics-dimension-user_loginSQLMesh
octolytics-dimension-repository_id540527604
octolytics-dimension-repository_nwoSQLMesh/sqlmesh
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id540527604
octolytics-dimension-repository_network_root_nwoSQLMesh/sqlmesh
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release309153364422b3c499922d1a2a6404910a58ed8e
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/SQLMesh/sqlmesh/pull/5804/commits/4ee6662a58f5e632aab2bb0acb1dd62328bd0f67#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FSQLMesh%2Fsqlmesh%2Fpull%2F5804%2Fcommits%2F4ee6662a58f5e632aab2bb0acb1dd62328bd0f67
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FSQLMesh%2Fsqlmesh%2Fpull%2F5804%2Fcommits%2F4ee6662a58f5e632aab2bb0acb1dd62328bd0f67
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Fcommits&source=header-repo&source_repo=SQLMesh%2Fsqlmesh
Reloadhttps://github.com/SQLMesh/sqlmesh/pull/5804/commits/4ee6662a58f5e632aab2bb0acb1dd62328bd0f67
Reloadhttps://github.com/SQLMesh/sqlmesh/pull/5804/commits/4ee6662a58f5e632aab2bb0acb1dd62328bd0f67
Reloadhttps://github.com/SQLMesh/sqlmesh/pull/5804/commits/4ee6662a58f5e632aab2bb0acb1dd62328bd0f67
Please reload this pagehttps://github.com/SQLMesh/sqlmesh/pull/5804/commits/4ee6662a58f5e632aab2bb0acb1dd62328bd0f67
SQLMesh https://github.com/SQLMesh
sqlmeshhttps://github.com/SQLMesh/sqlmesh
Notifications https://github.com/login?return_to=%2FSQLMesh%2Fsqlmesh
Fork 417 https://github.com/login?return_to=%2FSQLMesh%2Fsqlmesh
Star 3.2k https://github.com/login?return_to=%2FSQLMesh%2Fsqlmesh
Code https://github.com/SQLMesh/sqlmesh
Issues 218 https://github.com/SQLMesh/sqlmesh/issues
Pull requests 46 https://github.com/SQLMesh/sqlmesh/pulls
Discussions https://github.com/SQLMesh/sqlmesh/discussions
Actions https://github.com/SQLMesh/sqlmesh/actions
Projects https://github.com/SQLMesh/sqlmesh/projects
Security and quality 0 https://github.com/SQLMesh/sqlmesh/security
Insights https://github.com/SQLMesh/sqlmesh/pulse
Code https://github.com/SQLMesh/sqlmesh
Issues https://github.com/SQLMesh/sqlmesh/issues
Pull requests https://github.com/SQLMesh/sqlmesh/pulls
Discussions https://github.com/SQLMesh/sqlmesh/discussions
Actions https://github.com/SQLMesh/sqlmesh/actions
Projects https://github.com/SQLMesh/sqlmesh/projects
Security and quality https://github.com/SQLMesh/sqlmesh/security
Insights https://github.com/SQLMesh/sqlmesh/pulse
Sign up for GitHub https://github.com/signup?return_to=%2FSQLMesh%2Fsqlmesh%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FSQLMesh%2Fsqlmesh%2Fissues%2Fnew%2Fchoose
StuffbyYukihttps://github.com/StuffbyYuki
SQLMesh:mainhttps://github.com/SQLMesh/sqlmesh/tree/main
j-hartshorn:fix/local-only-formathttps://github.com/j-hartshorn/sqlmesh/tree/fix/local-only-format
Conversation 7 https://github.com/SQLMesh/sqlmesh/pull/5804
Commits 22 https://github.com/SQLMesh/sqlmesh/pull/5804/commits
Checks 32 https://github.com/SQLMesh/sqlmesh/pull/5804/checks
Files changed 4 https://github.com/SQLMesh/sqlmesh/pull/5804/files
feat: skip state-sync for the format command https://github.com/SQLMesh/sqlmesh/pull/5804/commits/4ee6662a58f5e632aab2bb0acb1dd62328bd0f67#top
Show all changes 22 commits https://github.com/SQLMesh/sqlmesh/pull/5804/files
5c43b3d docs: spec local-only format and lint j-hartshorn May 21, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/5c43b3d5a194a3d0629c5db16e15bd2ff3fb7462
15bf65b docs: plan local-only format and lint j-hartshorn May 21, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/15bf65bb8a8a061ed6387fe3472eda48d51db2be
82e0487 feat: add load_state flag to Context j-hartshorn May 21, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/82e04876fe53713e75b6a2a6552be229f2d8670e
addfc19 cli: run format and lint without state j-hartshorn May 21, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/addfc193464ad695db9686c08000b02903cdd32b
ea59785 fix: address whole-PR review findings j-hartshorn May 21, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/ea5978547ca64c3efda46a97c7427245f6d82019
95d2f9d polish: address fresh-eyes review j-hartshorn May 21, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/95d2f9d11f7d7248092025ad78bd67ea20b7f638
4c5c80e test: harden plan-still-loads-state guards j-hartshorn May 21, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/4c5c80e9741918ed04ad7429b9dc35acb3017820
8016f2a test: rename realistic-CI test, fix env_var note j-hartshorn May 21, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/8016f2ab2c3e316d8062ca332506e13d3f2d1490
fc1642f style: trim redundant comments and docstrings j-hartshorn May 21, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/fc1642f587cbc23d42c51d15b54923bffca3ec1f
6427cc8 chore: remove planning docs from PR j-hartshorn May 21, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/6427cc8c23359212f9e71f361f8258575bab2098
419d277 Merge branch 'main' into fix/local-only-format j-hartshorn May 22, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/419d277bd77ac4d18a53f2e3bf9c1229107a95ce
4ac598f Merge branch 'main' into fix/local-only-format j-hartshorn May 29, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/4ac598feeaaeceea99b710cf26df8c6d3cf08e92
c3a7bff Merge branch 'main' into fix/local-only-format j-hartshorn Jun 1, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/c3a7bffc6507d68cb1902c14f7b3071147947ef1
6574d62 Merge branch 'main' into fix/local-only-format j-hartshorn Jun 2, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/6574d622c5faf0ff2a72a704bf4054a8280b1e6d
1b26a63 Merge branch 'main' into fix/local-only-format j-hartshorn Jun 4, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/1b26a63e606c98a314f71f193665fb0b5aea0814
4ee6662 Merge branch 'main' into fix/local-only-format j-hartshorn Jun 8, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/4ee6662a58f5e632aab2bb0acb1dd62328bd0f67
b770ed9 Merge branch 'main' into fix/local-only-format j-hartshorn Jun 8, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/b770ed944a8653623c278d6b82109285433a0ffe
28cf93b Merge branch 'main' into fix/local-only-format j-hartshorn Jun 10, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/28cf93b639b026541c2bcec3e4c1504601cdd409
fadfe36 Add multi--paths regression test for local-only format/lint j-hartshorn Jun 10, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/fadfe36309ae8902f65c88f5695a98e759b8cd0d
c12af30 Narrow local-only state skip to format command j-hartshorn Jun 11, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/c12af30c584d6dfdb69a6260b87c92dfefc9da9d
076b1dc Add partial multi-repo format test and doc caveat j-hartshorn Jun 11, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/076b1dc009aa7a7d36bd343e8b78270878d23a44
167e72b Merge branch 'main' into fix/local-only-format j-hartshorn Jun 12, 2026 https://github.com/SQLMesh/sqlmesh/pull/5804/commits/167e72bd2e72c970191ed4d14e1b125ffc3bbe0d
Clear filters https://github.com/SQLMesh/sqlmesh/pull/5804/commits/4ee6662a58f5e632aab2bb0acb1dd62328bd0f67
Please reload this pagehttps://github.com/SQLMesh/sqlmesh/pull/5804/commits/4ee6662a58f5e632aab2bb0acb1dd62328bd0f67
Please reload this pagehttps://github.com/SQLMesh/sqlmesh/pull/5804/commits/4ee6662a58f5e632aab2bb0acb1dd62328bd0f67
Prev https://github.com/SQLMesh/sqlmesh/pull/5804/commits/1b26a63e606c98a314f71f193665fb0b5aea0814
Next https://github.com/SQLMesh/sqlmesh/pull/5804/commits/b770ed944a8653623c278d6b82109285433a0ffe
Please reload this pagehttps://github.com/SQLMesh/sqlmesh/pull/5804/commits/4ee6662a58f5e632aab2bb0acb1dd62328bd0f67
https://github.com/j-hartshorn
j-hartshornhttps://github.com/SQLMesh/sqlmesh/commits?author=j-hartshorn
view the diff.https://github.com/SQLMesh/sqlmesh/commit/4ee6662a58f5e632aab2bb0acb1dd62328bd0f67
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.