Skip to content

fix: Set Value is no longer offered on an Evaluate result - #2123

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/dap-no-set-value-without-a-parent-reference
Nov 22, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/dap-no-set-value-without-a-parent-reference

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Fixes #2117

What

With a debug adapter that supports setVariable, Set Value was enabled on an Evaluate result. Pressing Enter threw a NullPointerException in DAPValueModifier.setValue: nothing was sent to the adapter, and the editor stayed open.

Cause

  • DAPDebuggerEvaluator.evaluate creates the result with no parent variablesReference: new DAPValue(stackFrame, variable, null).
  • DAPValue.getModifier returned a modifier whenever the adapter supports setVariable and the value isn't read-only.
  • DAPValueModifier.setValue passes the null Integer to DAPClient.setVariable(String, int, String), and unboxing it throws.

Change

  • DAPValue.getModifier returns null for a value without a parent variablesReference, so IntelliJ disables Set Value for it.
  • docs/dap/UserGuide.md says so under "Set value".
  • No signature changes. DAP: support the setExpression request #2109 can add setExpression for these values.

Behaviour changes

  • Set Value is disabled on the result of Evaluate Expression, and on the top value of an expression's value popup.
  • Set Value on a variable in the Variables view doesn't change. Neither does Set Value on a variable inside an Evaluate result, whose parent is the result's variablesReference.
  • Watches don't change: IntelliJ already hides Set Value on a watch (XSetValueAction.update, in 2024.2, 2025.3 and 2026.3).

Test

DAPSetValueOfEvaluateResultSessionTest (new) attaches a debug session to a DAP server in the test process, which supports setVariable and not setExpression:

  • testSetValueIsNotOfferedForAnEvaluateResult: with the result selected, the XDebugger.SetValue action is disabled, the value has no modifier, and no setVariable is sent. On main it fails with "Set Value… isn't offered for an Evaluate result".
  • testSetValueOfAVariableSendsSetVariableWithTheReferenceOfItsParent (control): Set Value is enabled on a local, and Enter sends setVariable with the reference of the Locals scope. It passes before and after.
2024.2 2025.3 IU 2026.3
The new test on main 1 of 2 fails 1 of 2 fails 1 of 2 fails
dap tests with the fix 346 pass 346 pass 346 pass
Full suite with the fix 1861 tests, 0 failures, 7 skipped

Fixes redhat-developer#2117

With a debug adapter that supports setVariable, Set Value was enabled on the result of Evaluate Expression and of the
value popup of an expression. Pressing Enter threw a NullPointerException in DAPValueModifier.setValue: such a result
has no parent variablesReference, which setVariable needs. Nothing was sent to the debug adapter, and the editor stayed
open.

DAPValue.getModifier now returns no modifier for a value without a parent variablesReference, so IntelliJ disables Set
Value for it. A variable of the Variables view, and a variable inside an Evaluate result, can be set as before.
@lagergren lagergren added this to the 0.30.2 milestone Nov 22, 2026
@lagergren lagergren added bug Something isn't working dap Debugging Adapter Protocol labels Nov 22, 2026
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes

    • “Set Value…” is unavailable for Evaluate results that cannot be updated directly. Variables within those results can still be changed when supported.
    • Setting a variable now uses its parent container, helping ensure the change is applied to the correct variable.
  • Documentation

    • Clarified when “Set Value…” is unavailable for Evaluate results and that variables within a result can still be set.

Set Value is now unavailable for DAP values without a parent variable reference. The user guide documents this limitation, and session tests verify the behavior for Evaluate results and variables.

Changes: DAP Set Value behavior

Layer / File(s) Summary
Guard and document Set Value availability
src/main/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPValue.java, docs/dap/UserGuide.md
DAPValue.getModifier() now withholds the Set Value modifier when the parent variable reference is null. The guide states that Evaluate results cannot be set directly, while variables inside them can still be set.
Verify Set Value requests
src/test/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPSetValueOfEvaluateResultSessionTest.java
Session tests verify that setting a local variable sends setVariable with its name, parent reference, and entered value. They also verify that an Evaluate result does not offer Set Value and sends no setVariable request.

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: angelozerr, muescha

Merge Risk: Minimal · up to 22c29

Set Value is no longer offered for Evaluate results, which previously caused a NullPointerException. Editing variables in the Variables view is unchanged. No merge-blocking risk is identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: Set Value is no longer offered on an Evaluate result. The changeset makes DAPValue.getModifier return no modifier for values without a parent variablesReference, whic…
Description check Passed The description explains the bug (NullPointerException in DAPValueModifier.setValue when Set Value was offered on an Evaluate result), the cause, the change to DAPValue.getModifier, the documentation …
Linked Issues check Passed Issue #2117 requires that Set Value not be offered for values that setVariable cannot address, and that the attempt not throw. The reviewed head's DAPValue.getModifier() (src/main/java/com/redhat/devt…
Out of Scope Changes check Passed The PR changes three areas: the DAPValue.getModifier null-parent guard (directly implements #2117), a three-line note in docs/dap/UserGuide.md under 'Set value' describing that guard (documents the im…
Full details: Title check

Explanation

The title states the main change: Set Value is no longer offered on an Evaluate result. The changeset makes DAPValue.getModifier return no modifier for values without a parent variablesReference, which covers Evaluate results, and adds tests and docs for this behavior.

Full details: Description check

Explanation

The description explains the bug (NullPointerException in DAPValueModifier.setValue when Set Value was offered on an Evaluate result), the cause, the change to DAPValue.getModifier, the documentation update, behavior changes, and the new tests. It matches the changeset.

Full details: Linked Issues check

Explanation

Issue #2117 requires that Set Value not be offered for values that setVariable cannot address, and that the attempt not throw. The reviewed head's DAPValue.getModifier() (src/main/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPValue.java) returns null when parentVariablesReference is null, before it creates a DAPValueModifier. DAPDebuggerEvaluator.evaluate creates Evaluate and watch results with a null parent, so both are covered by this check. The unboxing path in DAPValueModifier.setValue is no longer reached for these values. Variables from scopes and their children keep a non-null parent reference (computeChildren passes parentVariablesReference), and canSetValue still gates on supportsSetVariable and readOnly, so Variables-view editing is unchanged. The docs/dap/UserGuide.md note is documentation only. The PR's test file DAPSetValueOfEvaluateResultSessionTest covers the disabled action and the control case, as described in the PR; I did not run it. The PR description says watches already hide Set Value in IntelliJ, while the issue reports F2 enabled on a watch. The code change applies to watches too, because they share the null-parent path, so the requirement is met either way. Diff reads failed (changed blobs unavailable), so this verdict relies on the reviewed head file content and the supplied PR evidence, not on a whole-PR diff.

Full details: Out of Scope Changes check

Explanation

The PR changes three areas: the DAPValue.getModifier null-parent guard (directly implements #2117), a three-line note in docs/dap/UserGuide.md under 'Set value' describing that guard (documents the implemented behavior), and a new test class DAPSetValueOfEvaluateResultSessionTest that checks the disabled action and the unchanged Variables-view path (supports the requirement). No unrelated code or signature changes are described. The raw summary lists no changes to declarations of public entities beyond the new test class and methods. The whole-PR diff could not be read, so this verdict is based on the reviewed head DAPValue.java and the PR and summary descriptions.

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: d7a63877-ae8c-4ec5-8012-54ff2fd11d49
Commits

Reviewing files that changed from the base of the PR and between 01c7a2a and 22c294a.

Files selected for processing: 3

  • docs/dap/UserGuide.md
  • src/main/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPValue.java
  • src/test/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPSetValueOfEvaluateResultSessionTest.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.

@codecov

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.66%. Comparing base (e927901) to head (22c294a).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2123      +/-   ##
==========================================
+ Coverage   50.48%   50.66%   +0.17%     
==========================================
  Files         816      816              
  Lines       33871    33897      +26     
  Branches     5287     6977    +1690     
==========================================
+ Hits        17101    17174      +73     
+ Misses      14114    14059      -55     
- Partials     2656     2664       +8     

☔ 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 merged commit ab2a8ea into redhat-developer:main Nov 22, 2026
9 checks passed
lagergren added a commit to lagergren/lsp4ij that referenced this pull request Nov 23, 2026
…request

With a debug adapter that supports 'setExpression' (supportsSetExpression),
"Set Value..." is offered on the result of Evaluate Expression and on the
top value of an expression's value popup, and assigns the new value to the
evaluated expression. redhat-developer#2123 hid it there, since 'setVariable' can't name a
value without a parent 'variablesReference'.

DAPValue.getModifier chooses the request:
- a variable with a parent 'variablesReference' is set with 'setVariable'
  as before; only when the adapter doesn't support 'setVariable' is it set
  with 'setExpression' of its 'evaluateName', as in VS Code
  (debugModel.ts), and of the resolved variable's for a lazy variable;
- a value without a parent, such as an Evaluate result, is set with
  'setExpression' of its expression, and not at all without it;
- a value marked read-only is never set.

The request sends the expression, the typed value, the frame and the
session's value format. Its answer updates the shown variable: value,
type, variablesReference (0 when left out, so the children reload),
named and indexed counts, presentationHint, memoryReference and
valueLocationReference.

IntelliJ hides "Set Value..." on a watch, where editing changes the
watch's expression, so watches don't change.

Fixes redhat-developer#2109
lagergren added a commit that referenced this pull request Nov 24, 2026
…request

With a debug adapter that supports 'setExpression' (supportsSetExpression),
"Set Value..." is offered on the result of Evaluate Expression and on the
top value of an expression's value popup, and assigns the new value to the
evaluated expression. #2123 hid it there, since 'setVariable' can't name a
value without a parent 'variablesReference'.

DAPValue.getModifier chooses the request:
- a variable with a parent 'variablesReference' is set with 'setVariable'
  as before; only when the adapter doesn't support 'setVariable' is it set
  with 'setExpression' of its 'evaluateName', as in VS Code
  (debugModel.ts), and of the resolved variable's for a lazy variable;
- a value without a parent, such as an Evaluate result, is set with
  'setExpression' of its expression, and not at all without it;
- a value marked read-only is never set.

The request sends the expression, the typed value, the frame and the
session's value format. Its answer updates the shown variable: value,
type, variablesReference (0 when left out, so the children reload),
named and indexed counts, presentationHint, memoryReference and
valueLocationReference.

IntelliJ hides "Set Value..." on a watch, where editing changes the
watch's expression, so watches don't change.

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

Labels

bug Something isn't working dap Debugging Adapter Protocol

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DAP: Set Value on an Evaluate result throws a NullPointerException

1 participant