Title: NullReferenceException in OnInitialize on Linux when the initialize request includes workspaceFolders (v4.6.0) · Issue #2300 · PowerShell/PowerShellEditorServices · GitHub
Open Graph Title: NullReferenceException in OnInitialize on Linux when the initialize request includes workspaceFolders (v4.6.0) · Issue #2300 · PowerShell/PowerShellEditorServices
X Title: NullReferenceException in OnInitialize on Linux when the initialize request includes workspaceFolders (v4.6.0) · Issue #2300 · PowerShell/PowerShellEditorServices
Description: On PSES v4.6.0 running on Linux, an LSP initialize whose params include a workspaceFolders array throws a NullReferenceException inside the server's own OnInitialize handler, on the path that adds the workspace folders. The handshake doe...
Open Graph Description: On PSES v4.6.0 running on Linux, an LSP initialize whose params include a workspaceFolders array throws a NullReferenceException inside the server's own OnInitialize handler, on the path that adds ...
X Description: On PSES v4.6.0 running on Linux, an LSP initialize whose params include a workspaceFolders array throws a NullReferenceException inside the server's own OnInitialize handler, on the path that a...
Opengraph URL: https://github.com/PowerShell/PowerShellEditorServices/issues/2300
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"NullReferenceException in OnInitialize on Linux when the initialize request includes workspaceFolders (v4.6.0)","articleBody":"On PSES `v4.6.0` running on Linux, an LSP `initialize` whose `params` include a\n`workspaceFolders` array throws a `NullReferenceException` inside the server's own\n`OnInitialize` handler, on the path that adds the workspace folders. The handshake\ndoes not complete -- no `initialize` response is returned -- so the server is unusable\nfor any client that sends `workspaceFolders` on this platform.\n\nThe same `initialize`, byte-for-byte, completes normally on Windows. Dropping\n`workspaceFolders` and relying on `rootUri` alone avoids the exception on Linux. The\nplatform asymmetry is the notable part: a client whose handshake is verified on\nWindows silently fails on Linux at exactly this step.\n\nThis is distinct from the rename-handler NRE (#2297 / PR #2299): different trigger\n(`workspaceFolders`, not an omitted `rename` capability), a different code path, and\nLinux-only rather than cross-platform.\n\n## Environment\n\n- PSES: `v4.6.0` (GitHub release asset `PowerShellEditorServices.zip`)\n- Host: PowerShell 7 (`pwsh`)\n- OS: Linux (reproduced on the GitHub Actions `ubuntu-latest` runner); **Windows is unaffected**\n- Transport: `Start-EditorServices.ps1 -Stdio`\n\n## Steps to reproduce\n\n1. Launch PSES over stdio on Linux with `-NoLogo -NoProfile`, logging to a file.\n\n2. Send an LSP `initialize` whose `params` include a `workspaceFolders` array, e.g.:\n\n ```json\n {\n \"processId\": 12345,\n \"clientInfo\": { \"name\": \"repro\", \"version\": \"1.0.0\" },\n \"rootUri\": \"file:///home/runner/work/example\",\n \"workspaceFolders\": [\n { \"uri\": \"file:///home/runner/work/example\", \"name\": \"workspace\" }\n ],\n \"capabilities\": { \"textDocument\": { \"rename\": { \"prepareSupport\": false } } }\n }\n ```\n\n (The `rename` capability is declared deliberately, to keep the separate v4.6.0\n PrepareRename NRE -- #2297 -- out of the picture; this report is about\n `workspaceFolders`.)\n\n3. Observe on Linux: no `initialize` **response** is returned, and the PSES log\n records a `NullReferenceException` in the `OnInitialize` handler on the\n workspace-folders add path. The NRE stack captured during debugging points at\n `PsesLanguageServer.cs` around the `OnInitialize` workspaceFolders handling\n (line numbers should be confirmed against the v4.6.0 source by a maintainer).\n\n## The one-line delta that proves the cause\n\nRe-send the same `initialize` with **`workspaceFolders` removed** and nothing else\nchanged:\n\n ```json\n {\n \"processId\": 12345,\n \"clientInfo\": { \"name\": \"repro\", \"version\": \"1.0.0\" },\n \"rootUri\": \"file:///home/runner/work/example\",\n \"capabilities\": { \"textDocument\": { \"rename\": { \"prepareSupport\": false } } }\n }\n ```\n\nOn Linux the handshake now completes and diagnostics flow. The only difference is the\npresence of the `workspaceFolders` array.\n\n## Expected\n\nSending `workspaceFolders` on `initialize` -- a standard, optional LSP field -- must\nnot throw inside `OnInitialize`. The workspace-folders add path should null-guard\nwhatever it dereferences (treat an empty/uninitialized collection as \"no folders yet\")\nrather than throwing, and it must behave the same on Linux as on Windows.\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's Windows CI legs\nalways passed this handshake; only the Linux leg surfaced the NRE. The plugin now\nomits `workspaceFolders` to work around it (it opens each file explicitly via\n`didOpen`/`didChange`, so multi-root folders are not needed for diagnostics), but the\nroot cause should be fixed for any client that legitimately sends `workspaceFolders`\non Linux.\n","author":{"url":"https://github.com/manderse21","@type":"Person","name":"manderse21"},"datePublished":"2026-06-10T14:50:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/2300/PowerShellEditorServices/issues/2300"}
| 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:f008ebda-3f57-c764-29eb-b72e602fcbc1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BC3C:305E50:527AD28:740E627:6A570E26 |
| html-safe-nonce | b29aada20bac4ccd67a6ccac060f4f96aea0d5a261815b1bc66311e04a564a04 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzNDOjMwNUU1MDo1MjdBRDI4Ojc0MEU2Mjc6NkE1NzBFMjYiLCJ2aXNpdG9yX2lkIjoiMjU0MzA1NzA0NDA1MzEwMjExOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c05f890dcac6fac7eed924ee0439c759e78de18b801d181ba45f97b5c2460026 |
| hovercard-subject-tag | issue:4632352588 |
| 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/2300/issue_layout |
| twitter:image | https://opengraph.githubassets.com/20aa15170c6bccb1a039608ce6373c94450f9b47d1f980f6cf302f8de5a8accd/PowerShell/PowerShellEditorServices/issues/2300 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/20aa15170c6bccb1a039608ce6373c94450f9b47d1f980f6cf302f8de5a8accd/PowerShell/PowerShellEditorServices/issues/2300 |
| og:image:alt | On PSES v4.6.0 running on Linux, an LSP initialize whose params include a workspaceFolders array throws a NullReferenceException inside the server's own OnInitialize handler, on the path that adds ... |
| 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