Title: PrepareRename throws NullReferenceException when an LSP client omits the `rename` capability (v4.6.0) · Issue #2297 · PowerShell/PowerShellEditorServices · GitHub
Open Graph Title: PrepareRename throws NullReferenceException when an LSP client omits the `rename` capability (v4.6.0) · Issue #2297 · PowerShell/PowerShellEditorServices
X Title: PrepareRename throws NullReferenceException when an LSP client omits the `rename` capability (v4.6.0) · Issue #2297 · PowerShell/PowerShellEditorServices
Description: Summary In PSES v4.6.0, an LSP initialize whose capabilities.textDocument omits rename leaves the prepare-rename handler dereferencing a null client RenameCapability. Observed effect: the server never returns an initialize response (the ...
Open Graph Description: Summary In PSES v4.6.0, an LSP initialize whose capabilities.textDocument omits rename leaves the prepare-rename handler dereferencing a null client RenameCapability. Observed effect: the server ne...
X Description: Summary In PSES v4.6.0, an LSP initialize whose capabilities.textDocument omits rename leaves the prepare-rename handler dereferencing a null client RenameCapability. Observed effect: the server ne...
Opengraph URL: https://github.com/PowerShell/PowerShellEditorServices/issues/2297
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PrepareRename throws NullReferenceException when an LSP client omits the `rename` capability (v4.6.0)","articleBody":"## Summary\n\nIn PSES `v4.6.0`, an LSP `initialize` whose `capabilities.textDocument` **omits**\n`rename` leaves the prepare-rename handler dereferencing a null client\n`RenameCapability`. Observed effect: the server never returns an `initialize`\nresponse (the handshake hangs) and the PSES log records a `NullReferenceException`\non the rename-handler path.\n\nDeclaring even a **minimal** `rename` capability avoids it and the handshake\ncompletes normally. This inverts the usual expectation that omitting an optional\nclient capability is always safe, so it is easy to hit from a minimal or hand-rolled\nLSP client.\n\n## Environment\n\n- PSES: `v4.6.0` (GitHub release asset `PowerShellEditorServices.zip`)\n- Host: PowerShell 7.6.2 (`pwsh`) and Windows PowerShell 5.1 -- reproduced on both\n- OS: Windows 11\n- Transport: `Start-EditorServices.ps1 -Stdio`\n\n## Steps to reproduce\n\n1. Launch PSES over stdio (paths trimmed for readability):\n\n ```\n pwsh -NoLogo -NoProfile -ExecutionPolicy Bypass -File \u003cPSES\u003e/Start-EditorServices.ps1 \\\n -HostName repro -HostProfileId repro -HostVersion 1.0.0 -Stdio \\\n -BundledModulesPath \u003cbundle\u003e -LogPath \u003clog\u003e -LogLevel Diagnostic \\\n -SessionDetailsPath \u003csession.json\u003e\n ```\n\n2. Send an LSP `initialize` whose `textDocument` capabilities cover the usual\n entries but **omit** `rename`:\n\n ```json\n {\n \"capabilities\": {\n \"textDocument\": {\n \"synchronization\": { \"didSave\": true },\n \"publishDiagnostics\": { \"relatedInformation\": true },\n \"hover\": {},\n \"definition\": {}\n }\n }\n }\n ```\n\n3. Observe: no `initialize` **response** is returned (the handshake hangs), and the\n PSES log shows a `NullReferenceException` in the rename-handler path.\n\n## The one-line delta that proves the cause\n\nRe-send `initialize` with a minimal `rename` capability declared and nothing else\nchanged:\n\n```json\n{\n \"capabilities\": {\n \"textDocument\": {\n \"synchronization\": { \"didSave\": true },\n \"publishDiagnostics\": { \"relatedInformation\": true },\n \"hover\": {},\n \"definition\": {},\n \"rename\": { \"prepareSupport\": false }\n }\n }\n}\n```\n\nThe handshake now completes and diagnostics flow. The only difference is the\npresence of the `rename` capability object.\n\n## Expected\n\nOmitting the optional `rename` capability must not break `initialize`. The\nprepare-rename handler should null-guard the client `RenameCapability` (treat absent\nas \"client does not support rename\") rather than dereferencing it.\n\n## Context\n\nFound while building a Claude Code plugin that drives PSES over stdio\n(https://github.com/manderse21/claude-powershell-lsp). The plugin now declares a\nminimal `rename` capability specifically to dodge this, but the root cause should be\nfixed for any client that legitimately omits it.\n","author":{"url":"https://github.com/manderse21","@type":"Person","name":"manderse21"},"datePublished":"2026-06-06T19:53:48.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/2297/PowerShellEditorServices/issues/2297"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1acf27ba-59bf-48bb-5bf1-557d092989d1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AE80:C60D:61804:8CBDD:6A571C26 |
| html-safe-nonce | b832bdab488726b7fd3ddf46853d0c1315298349577f2def53f6d7d1d9545eef |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTgwOkM2MEQ6NjE4MDQ6OENCREQ6NkE1NzFDMjYiLCJ2aXNpdG9yX2lkIjoiMTE0MTM2MDM4OTYwOTk1MzY2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d0e23caf976c2151c1ca0f72e4b35480ceee0dc16702c70ed2c171b739250067 |
| hovercard-subject-tag | issue:4604922201 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShellEditorServices/2297/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4c5c39d49acb8bdf66a5df24d470db25003c1d6e68a101b0eac31b5f9d425b48/PowerShell/PowerShellEditorServices/issues/2297 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4c5c39d49acb8bdf66a5df24d470db25003c1d6e68a101b0eac31b5f9d425b48/PowerShell/PowerShellEditorServices/issues/2297 |
| og:image:alt | Summary In PSES v4.6.0, an LSP initialize whose capabilities.textDocument omits rename leaves the prepare-rename handler dereferencing a null client RenameCapability. Observed effect: the server ne... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | manderse21 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4e7a7296a3830877cf21a6ad2a972c9e618a48915e03966cf0c53eb08e5aad98 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShellEditorServices git https://github.com/PowerShell/PowerShellEditorServices.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 36031537 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShellEditorServices |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36031537 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShellEditorServices |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2576d1f0198cf1588faf2edf27f1ed120903be10 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width