fix(lsp): read self.context_state instead of stale local variable in _context_get_or_load#5747
Open
jthurlburt wants to merge 1 commit intoSQLMesh:mainfrom
Open
fix(lsp): read self.context_state instead of stale local variable in _context_get_or_load#5747jthurlburt wants to merge 1 commit intoSQLMesh:mainfrom
jthurlburt wants to merge 1 commit intoSQLMesh:mainfrom
Conversation
…_context_get_or_load
_context_get_or_load captures self.context_state into a local variable
`state` at the top of the method. After _create_lsp_context() or
_ensure_context_for_document() successfully updates self.context_state
to ContextLoaded, the final check on line 1077 reads the stale local
`state` (still NoContext) instead of self.context_state.
This causes the method to always raise RuntimeError("Context failed to
load") on the first didOpen, even when context loading succeeds. The
LSP logs "Loaded SQLMesh Context" then immediately crashes. In VS Code,
this puts the client into a permanent "Client got disposed and can't be
restarted" state.
Signed-off-by: jthurlburt <jthurlburt818@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_context_get_or_loadcapturesself.context_stateinto local variablestateat line 1065_create_lsp_context()or_ensure_context_for_document()successfully updatesself.context_statetoContextLoaded, the final check at line 1077 reads the stale localstate(stillNoContext) instead ofself.context_stateRuntimeError("Context failed to load")on the firstdidOpen, even when context loading succeedsImpact
The LSP logs "Loaded SQLMesh Context" then immediately crashes on the first
textDocument/didOpen. In VS Code, this puts the extension client into a permanent "Client got disposed and can't be restarted" state. Affects both thespecified_pathscode path (viainitializationOptions.project_paths) and the_ensure_context_for_documentfallback path.Fix
Read
self.context_stateinstead of the stale localstatevariable on lines 1077-1078.Test plan
make stylepasses (ruff, ruff-format, mypy, valid migrations)