Summary
When trying to debug a minimal Scala 3 project in Zed using the Scala/Metals extension, the debugger fails with:
invalid value: integer -1, expected u64
The project itself compiles and runs successfully via sbt run, so this appears to be an issue in Zed's DAP client deserialization rather than in the Scala code or sbt setup.
This looks similar to previous JVM/DAP issues where a debug adapter sends -1 for a field such as a stack frame line number when no source location is available, while Zed expects an unsigned integer (u64).
Environment
OS: Windows
Zed version: <please fill in>
Scala extension version: <please fill in>
Scala version: 3.3.5
sbt version: 1.12.11
JDK: Java 21
Metals version: <please fill in if known>
Minimal reproduction project
build.sbt
ThisBuild / scalaVersion := "3.3.5"
lazy val root = (project in file("."))
.settings(
name := "test",
Compile / mainClass := Some("com.anjunar.Main")
)
src/main/scala/com/anjunar/Main.scala
package com.anjunar
object Main {
def main(args: Array[String]): Unit = {
println("Hello World!")
println("Hello World!")
println("Hello World!")
}
}
.zed/debug.json
Steps to reproduce
-
Open the minimal Scala project in Zed.
-
Make sure the Scala/Metals extension is installed and Metals has imported the sbt build.
-
Add a breakpoint in Main.scala, for example on one of the println lines.
-
Start the debug configuration:
Debug Scala Main (Metals launch)
-
The debugger fails with:
invalid value: integer `-1`, expected u64
Expected behavior
Zed should start the debug session successfully, stop at the breakpoint, and display stack frames / variables.
If the debug adapter sends -1 for a field like a stack frame line number where no source location exists, Zed should either accept it or normalize/ignore it instead of failing the whole debug session.
Actual behavior
The debug session fails with:
invalid value: integer `-1`, expected u64
Additional notes
The project itself runs fine outside the debugger:
Output:
Hello World!
Hello World!
Hello World!
So the issue seems specific to the Zed debugger / DAP deserialization path.
This may be related to JVM debug adapters sending -1 for source-less stack frames. Previous similar reports mention StackFrame.line or similar DAP fields being deserialized as u64 even though the adapter may return -1.
A more robust behavior would be to tolerate -1 from JVM debug adapters, or map it to 0 / None for fields where missing source locations are expected.
Summary
When trying to debug a minimal Scala 3 project in Zed using the Scala/Metals extension, the debugger fails with:
invalid value: integer
-1, expected u64The project itself compiles and runs successfully via
sbt run, so this appears to be an issue in Zed's DAP client deserialization rather than in the Scala code or sbt setup.This looks similar to previous JVM/DAP issues where a debug adapter sends
-1for a field such as a stack frame line number when no source location is available, while Zed expects an unsigned integer (u64).Environment
Minimal reproduction project
build.sbtsrc/main/scala/com/anjunar/Main.scala.zed/debug.json[ { "label": "Debug Scala Main (Metals launch)", "adapter": "Metals", "request": "launch", "mainClass": "com.anjunar.Main", "args": [], "jvmOptions": [], "env": {} } ]Steps to reproduce
Open the minimal Scala project in Zed.
Make sure the Scala/Metals extension is installed and Metals has imported the sbt build.
Add a breakpoint in
Main.scala, for example on one of theprintlnlines.Start the debug configuration:
The debugger fails with:
Expected behavior
Zed should start the debug session successfully, stop at the breakpoint, and display stack frames / variables.
If the debug adapter sends
-1for a field like a stack frame line number where no source location exists, Zed should either accept it or normalize/ignore it instead of failing the whole debug session.Actual behavior
The debug session fails with:
Additional notes
The project itself runs fine outside the debugger:
Output:
So the issue seems specific to the Zed debugger / DAP deserialization path.
This may be related to JVM debug adapters sending
-1for source-less stack frames. Previous similar reports mentionStackFrame.lineor similar DAP fields being deserialized asu64even though the adapter may return-1.A more robust behavior would be to tolerate
-1from JVM debug adapters, or map it to0/Nonefor fields where missing source locations are expected.