π Template Sync Required
Changes from the upstream vscode-python-tools-extension-template have not yet been incorporated into this repository.
Source PR
Summary
The template fixed a bug in bundled/tool/lsp_jsonrpc.py where the result variable was assigned inside the if "error" in (redacted) block but then referenced unconditionally in the return RpcRunResult(result, "")statement after that block. This causes aNameError: name 'result' is not definedwhenever the JSON-RPC response contains no"error"key (i.e., on success). The fix moves theresult` assignment to before the error check so it is always initialized.
Files with missing changes
bundled/tool/lsp_jsonrpc.py: The result = data["result"] if "result" in data else "" assignment is still indented inside the if "error" in (redacted) block, but is used outside it. This will raise NameError` on any successful RPC response.
Current (buggy) code in run_over_json_rpc:
if "error" in data:
result = data["result"] if "result" in data else "" # β only assigned when error present
error = data["error"]
if data.get("exception", False):
return RpcRunResult(result, "", error)
return RpcRunResult(result, error)
return RpcRunResult(result, "") # β NameError if no "error" in data
Suggested fix
Move the result assignment before the `if "error" in (redacted) block:
--- a/bundled/tool/lsp_jsonrpc.py
+++ b/bundled/tool/lsp_jsonrpc.py
@@ -237,9 +237,9 @@ def run_over_json_rpc(
if data["id"] != msg_id:
return RpcRunResult(
"", f"Invalid result for request: {json.dumps(msg, indent=4)}"
)
+ result = data["result"] if "result" in data else ""
if "error" in data:
- result = data["result"] if "result" in data else ""
error = data["error"]
if data.get("exception", False):
Files skipped
None β all changes affect shared template infrastructure.
π€ This issue was auto-generated by the extension-template-sync workflow.
Generated by Extension Template Sync Β· β·
π Template Sync Required
Changes from the upstream vscode-python-tools-extension-template have not yet been incorporated into this repository.
Source PR
Summary
The template fixed a bug in
bundled/tool/lsp_jsonrpc.pywhere theresultvariable was assigned inside theif "error" in (redacted) block but then referenced unconditionally in thereturn RpcRunResult(result, "")statement after that block. This causes aNameError: name 'result' is not definedwhenever the JSON-RPC response contains no"error"key (i.e., on success). The fix moves theresult` assignment to before the error check so it is always initialized.Files with missing changes
bundled/tool/lsp_jsonrpc.py: Theresult = data["result"] if "result" in data else ""assignment is still indented inside theif "error" in (redacted) block, but is used outside it. This will raiseNameError` on any successful RPC response.Current (buggy) code in
run_over_json_rpc:Suggested fix
Move the
resultassignment before the `if "error" in (redacted) block:Files skipped
None β all changes affect shared template infrastructure.
π€ This issue was auto-generated by the
extension-template-syncworkflow.