fix(dap): skip enrich_config for attach mode#494
Merged
Conversation
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) <[email protected]>
s1n7ax
approved these changes
Jun 6, 2026
Member
|
Thanks for the contribution <3 |
Contributor
Author
|
@s1n7ax np... it is mostly claude code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Setup:enrich_config(lua/java-dap/setup.lua:41) asserts thatmainClassis present, but attach configs don't have one and don'tneed one — the JVM is already running and chose its own main class,
classpath, and java executable.
The assert fires before any check on
requesttype, so every JavaDAP attach config fails today unless callers pre-populate dummy
values for the five fields the early-return checks (
mainClass,projectName,modulePaths,classPaths,javaExec).This PR adds an early return for
config.request == 'attach',skipping the launch-specific enrichment (
build_workspace,resolve_classpath,resolve_java_executable) which are allmeaningless for an already-running JVM.
Reproduction
Register a Java attach config in
dap.configurations.java:Start a JDWP-listening JVM (e.g.
mvn spring-boot:run -Dspring-boot.run.jvmArguments='-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005'), then:DapContinueand pick that config.Before this PR:
After this PR: the attach proceeds, the DAP session initialises,
and breakpoints work as expected.
Why the early-return location
The existing five-field early-return (lines 45-47) lets callers
satisfy the assert by passing dummy values. That works as a
workaround but is unintuitive — attach configs shouldn't have to
fake fields they semantically don't have. Adding the
request == 'attach'short-circuit ahead of it expresses the actualinvariant: attach configs need no enrichment, full stop.
Test plan
:DapContinue→pick attach config → DAP session attaches, dap-ui opens, breakpoints
fire on the running JVM.
request == 'launch'configs still go through thefull enrichment path (no regression — the early return only fires on
'attach').🤖 Generated with Claude Code