Skip to content

Commit ccd76f9

Browse files
fobbyalclaude
andauthored
fix(dap): skip enrich_config for attach mode (#494)
Setup:enrich_config asserts that mainClass is present, but attach configs don't have one and don't need one — the JVM is already running and chose its own main class, classpath, and java executable. The assert fires before any check on request type, making every attach config in nvim-dap fail unless callers pre-populate dummy values for the five fields the early-return checks. Adding an early return for `request == 'attach'` skips the launch-specific enrichment (build_workspace, classpath resolution, java executable resolution) which are all meaningless for an already- running JVM. Reproduction: register a Java attach config in dap.configurations.java with type='java', request='attach', hostName='127.0.0.1', port=5005, then :DapContinue. Today it errors with: To enrich the config, mainClass should already be present .../java-dap/setup.lua:54 After this fix, the attach proceeds and dap-ui opens against the running JVM as expected. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 602a5f7 commit ccd76f9

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lua/java-dap/setup.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ end
4141
function Setup:enrich_config(config)
4242
config = vim.deepcopy(config)
4343

44+
-- Attach configs don't need enriching — the JVM is already running and
45+
-- chose its own main class, classpath, and java executable. Without this
46+
-- short-circuit, the `assert(main, ...)` below fires because attach
47+
-- configs (correctly) have no mainClass.
48+
if config.request == 'attach' then
49+
return config
50+
end
51+
4452
-- skip enriching if already enriched
4553
if config.mainClass and config.projectName and config.modulePaths and config.classPaths and config.javaExec then
4654
return config

0 commit comments

Comments
 (0)