Skip to content

fix(dap): give the source position of a DAP value in a read action - #2006

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
muescha:fix/dap-value-source-position-read-action
Nov 17, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
muescha:fix/dap-value-source-position-read-action

Conversation

@muescha

@muescha muescha commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #2005

Summary

When a DAP session stops and the editor shows inline values, the IDE often reports "Read access is allowed from inside read-action only" from DAPValue.computeSourcePosition. DAPValue gave the source position to the navigatable in a thenAccept on the future of DAPStackFrame.getSourcePositionFor. While the variables context of the frame is still loading, that future completes on a pooled thread, outside a read action. The inline values callback of XValueNodeImpl then reads the document of the position with FileDocumentManager.getDocument.

New in 0.30.0: in 0.21.0 the future completed inside the read action of configureContext. #1781 moved the completion out of it.

Changes

  • DAPValue.setSourcePosition(future, navigatable) (new, package-private, static): gives the position to the navigatable in ReadAction.run once it is known, and gives nothing when there is no position. This matches JavaValue, which calls the navigatable in ReadAction.nonBlocking.
  • DAPValue.computeSourcePosition uses it. computeInlineDebuggerData and "Jump to Source" go through it as before.

On the EDT (the context is already loaded) the read action costs nothing. On a pooled thread it waits only for a running write action. The callback does little work: it compares files, gets the document and schedules the inlay with invokeLater.

Tests

  • DAPValueSourcePositionTest:
    • A position that becomes known on a pooled thread is given in a read action. This test fails without the fix (expected:<[true]> but was:<[false]>).
    • A position that is already known is given at once, in a read action.
    • No position gives nothing.

./gradlew test --tests 'com.redhat.devtools.lsp4ij.dap.*': 329 tests, all pass. ./gradlew buildPlugin: passes.

Checked in the IDE

Claude Code ran runIde (IntelliJ IDEA Community 2024.2 sandbox) and debugged a Python loop with the debugpy bundled in IntelliJ IDEA 2026.3, with a line breakpoint in the loop and inline values on:

  • Before (main, 21a3f42): in 9 stops the error came 4 times, at 3 of the stops.
  • After: in 9 stops, no error. The inline values are shown as before.

🤖 Generated with Claude Code

DAPValue.computeSourcePosition gave the position to the navigatable in a
thenAccept on the future of DAPStackFrame.getSourcePositionFor. When the
variables context of the frame was still loading, that future completed
on a pooled thread, outside a read action, and the inline values callback
of XValueNodeImpl reported "Read access is allowed from inside
read-action only" when it read the document. In 0.21.0 the future
completed inside the read action of configureContext; redhat-developer#1781 moved it
out. Now the navigatable is called in ReadAction.run, as JavaValue does.

Fixes redhat-developer#2005

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved the handling of source positions when results arrive asynchronously, helping ensure they are applied safely and consistently.
    • Null source positions are ignored, and already-available positions continue to be applied immediately.

DAPValue.computeSourcePosition now applies non-null source positions inside a read action. Tests cover delayed and already-completed futures, and verify that null positions are not delivered.

Changes: DAP Source Position

Layer / File(s) Summary
Apply source positions and verify access
src/main/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPValue.java, src/test/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPValueSourcePositionTest.java
computeSourcePosition delegates to a helper that applies non-null positions inside ReadAction.run. Tests check delivery during read access for delayed and completed futures, and non-delivery for a null position.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: angelozerr

Merge Risk: Minimal · up to 33d5f

This change makes DAP inline values and source positions read the position inside a read action, which fixes the intermittent read-access IDE error. It adds tests for delayed, already-completed and absent positions. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the primary change: DAP value source position is now given inside a read action, which matches the raw summary (DAPValue.computeSourcePosition delegates to a helper that applies posit…
Description check Passed The description is directly related to the changeset. It names the affected method (DAPValue.computeSourcePosition), the new setSourcePosition helper, the read-action change, the added DAPValueSourceP…
Linked Issues check Passed Issue #2005 requires that the navigatable of DAPValue.computeSourcePosition run in a read action, with a regression test for a future that completes on a pooled thread. At reviewed head, DAPValue.setS…
Out of Scope Changes check Passed The change touches DAPValue.java (computeSourcePosition refactored to a package-private static helper that applies the position in ReadAction.run) and adds DAPValueSourcePositionTest. Both connect dir…
Full details: Title check

Explanation

The title states the primary change: DAP value source position is now given inside a read action, which matches the raw summary (DAPValue.computeSourcePosition delegates to a helper that applies positions in ReadAction) and the objectives. It uses the conventional fix(dap) prefix and is specific enough for a teammate scanning history.

Full details: Description check

Explanation

The description is directly related to the changeset. It names the affected method (DAPValue.computeSourcePosition), the new setSourcePosition helper, the read-action change, the added DAPValueSourcePositionTest tests, and the manual IDE verification. It links issue #2005.

Full details: Linked Issues check

Explanation

Issue #2005 requires that the navigatable of DAPValue.computeSourcePosition run in a read action, with a regression test for a future that completes on a pooled thread. At reviewed head, DAPValue.setSourcePosition(future, navigatable) calls navigatable.setSourcePosition inside ReadAction.run when the position is non-null, and computeSourcePosition delegates to it. This matches the suggested fix in #2005 and the JavaValue pattern. The PR adds DAPValueSourcePositionTest with a case for a position completed on a pooled thread, which the PR reports fails without the fix. I read the DAPValue.java source at head. I did not read the test file; its content rests on the PR description and the change summary. The optional DebugVariableContext.getSourcePosition read-action wrapping in #2005 is a suggestion ('could'), not a stated requirement, so its absence does not fail this check.

Full details: Out of Scope Changes check

Explanation

The change touches DAPValue.java (computeSourcePosition refactored to a package-private static helper that applies the position in ReadAction.run) and adds DAPValueSourcePositionTest. Both connect directly to #2005. computeInlineDebuggerData and Jump to Source reuse computeSourcePosition, so their behavior stays the same. No unrelated changes were identified in the evidence reviewed. Limitation: I did not inspect the test file or the full changed-file list, so the assessment relies on the PR summary for those.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: aa0a9d59-e441-4e73-9a0c-93362882a99d
Commits

Reviewing files that changed from the base of the PR and between 21a3f42 and 33d5fd7.

Files selected for processing: 2

  • src/main/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPValue.java
  • src/test/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPValueSourcePositionTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@muescha

muescha commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.13%. Comparing base (21a3f42) to head (33d5fd7).

Files with missing lines Patch % Lines
...devtools/lsp4ij/dap/client/variables/DAPValue.java 50.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2006   +/-   ##
=======================================
  Coverage   49.13%   49.13%           
=======================================
  Files         812      812           
  Lines       32975    32975           
  Branches     5101     5101           
=======================================
+ Hits        16201    16202    +1     
+ Misses      14234    14230    -4     
- Partials     2540     2543    +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren lagergren added this to the 0.30.0 milestone Nov 17, 2026
@lagergren
lagergren merged commit 08c1fb7 into redhat-developer:main Nov 17, 2026
9 checks passed
@muescha
muescha deleted the fix/dap-value-source-position-read-action branch November 20, 2026 00:36
lagergren added a commit that referenced this pull request Nov 24, 2026
… request

"Jump to Source" on a variable which has a 'declarationLocationReference'
now asks the debug adapter where the declaration is, with the 'locations'
request, and opens the source of the answer at its line and column: a
local file, or the text of a source reference. lldb-dap gives the
reference to a variable whose declaration it knows.

The request is sent off the EDT, with sendInExecutionEpoch, so that the
reference of a value of an earlier stop is never sent. The position is
given to the navigatable in a read action, as before (#2005, #2006).

Without a reference, when the request fails or is refused because the
stop has ended, and when the answer has no location which can be opened,
Jump to Source searches the name of the variable in the file of its
frame, as it did before. The inline values keep using that search only: a
'locations' request for each value shown inline would cost too much, and
would move the values to their declarations.

The 'locations' request of a value and the resolution of its answer to a
position move from DAPJumpToValueSourceAction to DAPLocations, which both
jumps use. DAP gives a 'declarationLocationReference' to a Variable only,
not to the evaluate, setVariable and setExpression responses; Set Value
updates the variable in place, which keeps it.

Fixes #2115
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DAP: inline values report "Read access is allowed from inside read-action only" from DAPValue.computeSourcePosition

2 participants