Repository navigation
Closed
Description
What happens
With a debug adapter that supports setVariable, Set Value (F2) is enabled on an Evaluate result, and on the top value of an expression's value popup. Pressing Enter throws:
java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "com.redhat.devtools.lsp4ij.dap.client.variables.DAPValue.getParentVariablesReference()" is null
at com.redhat.devtools.lsp4ij.dap.client.variables.DAPValueModifier.setValue(DAPValueModifier.java:34)
at com.intellij.xdebugger.impl.ui.DebuggerUIUtil.setTreeNodeValue(DebuggerUIUtil.java:472)
- Nothing is sent to the adapter, and the value keeps showing "Modifying value…".
- The exception also skips
super.doOKAction()inSetValueInplaceEditor.doOKAction, which hides the editor, so the editor stays open.
Reproduced on IntelliJ IDEA Community 2024.2 and 2025.3, with a test that drives Set Value through DebuggerUIUtil.setTreeNodeValue, as pressing Enter does.
Steps
- Debug with an adapter that has
supportsSetVariable, for example debugpy or vscode-js-debug. - Stop at a breakpoint.
- Evaluate
xin Evaluate Expression. - Select the result, press F2, type
42and press Enter.
Expected
Set Value isn't offered for a value that setVariable can't address, and it never throws. Set Value on a variable in the Variables view keeps working, as it does today.
Cause
On main (35eb012):
DAPDebuggerEvaluator.evaluatecreates the result with no parent reference:new DAPValue(stackFrame, variable, null)(DAPDebuggerEvaluator.java:131). Watches come through here too, but IntelliJ never offers Set Value on a watch (XSetValueAction.updatehides it for a watch node).DAPValue.getModifierreturns aDAPValueModifierwhen the adapter supportssetVariableand the value isn't read-only. It doesn't look at the parent reference (DAPValue.java:99-105).DAPValueModifier.setValuepassesvalue.getParentVariablesReference(), anInteger, toDAPClient.setVariable(String, int, String)(DAPValueModifier.java:34, DAPClient.java:1473-1474). Unboxing null throws.
Suggested fix
- In
DAPValue.getModifier, return null whengetParentVariablesReference()is null. - DAP: support the setExpression request #2109 can then add
setExpressionfor these values.
Activity
[-]DAP: Set Value on a watch or an Evaluate result throws a NullPointerException[/-][+]DAP: Set Value on an Evaluate result throws a NullPointerException[/+]fix: Set Value is no longer offered on an Evaluate result (redhat-dev…