Repository navigation
fix: a DAP attach without a port is an error that names the field, and the Working directory and File take ~ and relative paths - #2302
Conversation
… configuration that names the field, not "port out of range:-1" In Attach mode, the client connects to the Port of the Attach tab. When that port can't be resolved, as `$port` when the DAP parameters have no `port` (the attach configuration of the ruby-rdbg template), LaunchUtils.resolveAttachPort gives -1, the run starts anyway, and the socket fails with `java.lang.IllegalArgumentException: port out of range:-1` in the console, which names neither the field nor the fix. DAPRunConfiguration.checkConfiguration now reports it as a RuntimeConfigurationError, which IntelliJ shows in the run configuration dialog and before the run, and which keeps the run from starting, since it could never connect: - `$port` without a number for `port` in the DAP parameters: `Attach port is missing: set "port" to a port number in the DAP parameters, or enter a port number instead of $port` - an empty port: `Attach port is missing: enter a port number in the Port field of the Attach tab` - a port which isn't a number: `Attach port "<text>" is not a number: ...` Only an attach that connects to that port is checked: with LSP4IJ's own descriptor, without a server or with a user-defined server. A Launch, a server from an extension point (whose descriptor can reach its Debug Adapter in another way for an attach, see DebugAdapterDescriptor.startServer(DebugMode)) and other run configurations are not, and DAP parameters which aren't JSON are left to the run, as before. Fixes redhat-developer#2293
…~ and relative paths, and a working directory that doesn't exist is a warning
The `Working directory` and the `File` of a DAP run configuration were used as they were typed. `~/docs/ruby-test` or
`src` isn't a directory to `new File(...)` in the IDE's process, so the working directory was dropped without a word and
the debug adapter started in the IDE's working directory, and `${file}` and `${workspaceFolder}` passed `~` or a relative
path on to the debug adapter, which knows neither.
At run time, in both fields, a leading `~` is now the user's home directory, and an absolute path stays exactly as it
is. A relative `Working directory` is resolved against the project's directory (`project.getBasePath()`). A relative
`File` is resolved against that resolved working directory when one is set, as the debug adapter, which runs there,
resolved it before, and otherwise against the project's directory, where the debug adapter ran without a working
directory. Nothing changes in the fields, in the settings editor or in what is stored: DAPRunConfigurationOptions gets
getResolvedWorkingDirectory(Project) and getResolvedFile(Project) next to the stored getters, and every place that uses
the values at run time takes them:
- DefaultDebugAdapterDescriptor: the working directory of the debug adapter's process, the file whose directory it runs
in without one, and the file type from the extension of the file
- LaunchUtils.getDapParameters: `${file}` and `${workspaceFolder}` in the DAP parameters
- DAPCommandLineState.getFile: the file in the title of the starting task
- DebugAdapterManager: the File of an existing configuration, compared with the path of a file to reuse that
configuration, through the new DAPRunConfiguration.getResolvedFile()
DAPRunConfiguration.checkConfiguration warns (RuntimeConfigurationWarning, the run still starts, as before) when a
working directory is set and, resolved, isn't a directory: `Working directory "<path>" is not an existing directory, so
the debug adapter cannot start in it: choose an existing directory, or clear the field`. The DAP user guide says so.
Behaviour change: a relative working directory, which ran in the IDE's own directory before, now resolves against the
project's directory. A relative File gives the same file as before, now as an absolute path: in the working directory,
or without one in the project's directory. Only the options of the generic DAP run configuration
(DAPRunConfigurationOptions) are resolved; the options of other run configurations are used as before.
Fixes redhat-developer#2299
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2302 +/- ##
==========================================
+ Coverage 58.51% 58.55% +0.03%
==========================================
Files 847 847
Lines 36501 36548 +47
Branches 7560 7575 +15
==========================================
+ Hits 21360 21400 +40
- Misses 12136 12156 +20
+ Partials 3005 2992 -13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…as it is, also on Windows On Windows, a path such as /working/directory has no drive, so FileUtil.isAbsolute says it isn't absolute, and the previous commit resolved it against the project's directory, to C:\working\directory. It names a directory from the root of the current drive, and the Debug Adapter got it as it is before: a path which starts with / or \ now stays as it is, as an absolute path does. LaunchUtilsPlatformTest failed on Windows CI with "expected:</working/directory> but was:<C:\working\directory>". Part of redhat-developer#2299
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action performed
|
…t changes only documentation, as for a pull request (#2309) Part of #2298: a push to main that changes only documentation skips the tests and the plugin verification, as a pull request of documentation only already does. ## Why `changes.yml` listed the files of a pull request only, so every push to main ran the whole test matrix and the verification against every IDE release, also for documentation only: the code of the commit before, which its own push had tested. The main push of #2300 (docs only) held two macOS runners of the organization's short pool in the queue for over 100 minutes, ahead of the pull requests behind it. ## What - **`changes.yml`:** on a push, the compare API lists the files of the whole range `before...after`, so that the several commits of a rebase merge count together. It is documentation only when every file is under `docs/` or a Markdown file at the root, as for a pull request. - **Still runs everything:** a push without a previous commit (the first of a branch), one whose range isn't only new commits (`status` other than `ahead`, as a rewritten history), and one of 300 files or more, which the API may cut. - **Build Plugin zip** still runs on every push: the plugin's description comes from `README.md`. - The `changes` jobs of `ci.yml` and `IJ.yml` get `contents: read`, for the compare API. ## Checked The step, run locally against main's history: | Push | Result | |---|---| | `10a04d91..a900e49`, #2300 (docs) | documentation only | | `ff1902e1..10a04d9`, #2289 (code) | runs everything | | `e25c0382..a900e49`, three merges at once | runs everything | | `01058929..e25c038`, #2294's rebase merge (docs and a template) | runs everything | | `0000…..a900e49`, a new branch | runs everything | | `4f30741e..a900e49`, a diverged range | runs everything | | pull requests #2300 / #2302 | documentation only / runs everything, as before | actionlint passes on the three workflows, and the branch merges cleanly with #2308. The push path itself runs only on main, so the first docs-only push after this merge is its real test.
…iJ has told the listeners of the first stop (#2304) `DAPRefusedResumeSessionTest.testAStopBeforeARefusedResumeAtABreakpointWhichDoesNotSuspendIsWhereTheSessionIsSuspended` failed once on the IU 2026.3 CI job of #2302, whose changes are unrelated: ``` The frames where the session paused since it ran to the breakpoint: only at the newer stop expected:<[3]> but was:<[1, 3]> ``` ## Cause: a race in the test IntelliJ marks a session suspended at a stop before it tells the session's listeners (`sessionPaused`), on the thread that suspended it, here a pool thread of the DAP client; in between it runs `logPositionReached` (checked in `XDebugSessionImpl` of 2024.2 and 2026.3). `debug()` returned as soon as the session showed the first stop, and `recordPauses()` then added its listener, which IntelliJ could still tell about that first stop: 1. pool thread: `positionReached` for stop 1, the session shows frame 1; 2. test thread: `debug()` sees it, `recordPauses()` adds its listener, Resume; 3. pool thread: `sessionPaused` for stop 1 reaches the new listener, recorded as frame 1; 4. then the stops that the test is about, and a pause at frame 3: `[1, 3]`. The product pauses once per stop and never at the stale stop. ## Fix The mock DAP server no longer stops by itself at `configurationDone`. `debug()` waits until the session exists and the server is configured (and has the breakpoint where there is one), adds a session listener, sends the first stop, and returns once IntelliJ has told that listener of the pause. A listener added from then on isn't told of it. All 14 tests start through `debug()`. ## Tests - **Deterministic reproduction:** a hold on IntelliJ's thread inside `logPositionReached` at the first stop, after the session shows the stop and before it tells the listeners. With the old test it fails every time with the CI message; with this one it passes. The hold isn't kept: it tests the test's own recording, and depends on an experimental extension point and a private method's name. - Headless: `dap.stepping.*` on 2024.2, 28 tests; `DAPRefusedResumeSessionTest` on IU 2026.3, 14 tests. No failure, error or skip. Test only, no change for users.
…expandUserHome, which IntelliJ 2025.3 schedules for removal Since #2302, the Working directory and the File of a DAP run configuration take a leading ~, which DAPRunConfigurationOptions.resolvePath expanded with FileUtil.expandUserHome. IntelliJ 2025.3 deprecates it and schedules it for removal, and the plugin verifier reports it against 2025.3 to 2026.3: it is the only API scheduled for removal that LSP4IJ uses. Its replacement, OSAgnosticPathUtil.expandUserHome, only exists from 2025.3. No other public API expands ~ on 2024.2 to 2026.3: EelPathUtils.expandUserHome takes an EelDescriptor and doesn't exist in 2024.2, and the file chooser's NioPathCompletion.expandHome is part of its text field. DAPRunConfigurationOptions.expandUserHome does what both platform methods do, in 2024.2 and in 2026.3: ~ alone is the user's home, a ~ before / or \ is replaced with it, and any other path, such as ~user/file, stays as it is. Nothing changes for the user. Fixes #2327
Fixes #2293 (Problem 2; Problem 1 was fixed by #2294) and #2299. Two commits, one per issue, for a rebase merge.
What
fix: a DAP attach whose port can't be resolved is an error in the run configuration that names the field (#2293)
In Attach mode,
DAPRunConfiguration.checkConfigurationnow reports an attach port thatLaunchUtils.resolveAttachPortcan't resolve, as aRuntimeConfigurationError. The dialog shows it, and IntelliJ shows it before the start, instead of the run failing at connect withjava.lang.IllegalArgumentException: port out of range:-1. An attach without a port can never connect, so the error blocks nothing that worked.$portwith no number forport:Attach port is missing: set "port" to a port number in the DAP parameters, or enter a port number instead of $portAttach port is missing: enter a port number in the Port field of the Attach tabAttach port "<text>" is not a number: enter a port number, or $port to take "port" from the DAP parametersOnly an attach with LSP4IJ's own descriptor is checked: a configuration without a server, or with a user-defined server (the templates). The descriptor of a server from an extension point can reach its debug adapter another way (#1798), so it isn't checked, nor is Launch mode or another run configuration class. DAP parameters that aren't valid JSON are left to the run, as before.
feat: the Working directory and File of a DAP run configuration take
~and relative paths, and a working directory that doesn't exist is a warning (#2299)The backward-compatible part of #2299: nothing changes in the fields, the settings editor or what is stored. At run time:
~is the home directory, in both fields;DAPRunConfigurationOptionsgetsgetResolvedWorkingDirectory(Project)andgetResolvedFile(Project)next to the stored getters, and every place that uses the values at run time takes them: the debug adapter's working directory and file type (DefaultDebugAdapterDescriptor),${file}and${workspaceFolder}(LaunchUtils.getDapParameters), the title of the starting task (DAPCommandLineState.getFile) and the reuse of a configuration for a file (DebugAdapterManager).checkConfigurationwarns (RuntimeConfigurationWarning; the run still starts, as before) when a working directory is set and, resolved, isn't a directory. The DAP user guide describes the paths and the warning.The display variants of #2299 (
~or macros in the field) are left out.Behaviour changes
$port, noportin the DAP parametersport out of range:-1src(relative)<project>/src~/docs/ruby-test$HOME/docs/ruby-testx.rbwith working directory/a/bx.rband resolved it in/a/b/a/b/x.rb, the same file, as an absolute path~/x/a.rbin${file}~/x/a.rbTests
DAPRunConfigurationCheckTest(14: the port check in each case, and the working directory warning),DAPRunConfigurationOptionsResolvedPathTest(6). Added toLaunchUtilsPlatformTest(${file},${workspaceFolder}) andDAPConfigurationWorkingDirectoryTest(relative and~working directories, reuse of a configuration whose File is relative, to the project or to the working directory).com.redhat.devtools.lsp4ij.dap.*, 630 tests, and after the File rule the 10 affected classes, 67 tests, with no failure, error or skip.