uni: Refactor udb dap messages#545
Open
JosephAbdo wants to merge 8 commits intouniconproject:masterfrom
Open
Conversation
Jafaral
reviewed
Mar 2, 2026
95175a5 to
04f996b
Compare
Member
|
@greptile review |
Greptile SummaryThis PR refactors the UDB DAP adapter layer by introducing a new Key changes and observations:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant VSCode as VS Code Client
participant JSON_HTTPSocket
participant get_request as Adapter.get_request()
participant DAP_Message
participant process_request as Adapter.process_request()
VSCode->>JSON_HTTPSocket: HTTP-framed DAP JSON
JSON_HTTPSocket->>JSON_HTTPSocket: get_http_header()
JSON_HTTPSocket->>JSON_HTTPSocket: get_data()
JSON_HTTPSocket->>JSON_HTTPSocket: jtous(body)
JSON_HTTPSocket-->>get_request: raw table t
get_request->>DAP_Message: DAP_Message().from_table(t)
alt t["type"] present
DAP_Message-->>get_request: self (valid msg)
get_request-->>process_request: suspend msg
else t["type"] absent
DAP_Message-->>get_request: fail (skipped)
end
process_request->>process_request: msg.get_seq() / get_command() / get_arguments()
process_request->>VSCode: writes(sock, build_response/build_event)
Prompt To Fix All With AIThis is a comment left during a code review.
Path: uni/udb/adapter.icn
Line: 171
Comment:
**`get_body()` always returns a table, making `\response_body` redundant**
`msg.get_body()` is declared as `return \t["body"] | table()` — it never returns `&null`. This means `\response_body` on this line is always non-null, so the guard is unconditionally true and provides no protection. The only real filter is the `member(response_body, "shellProcessId")` call, which is correct.
This is not a runtime bug today, but the misleading `\response_body &` check implies `response_body` can be null (which it cannot), and could lead a future developer to trust it as a meaningful guard.
Consider removing the redundant check to keep the intent clear:
```suggestion
"runInTerminal" : { if member(response_body, "shellProcessId") then shellProcessId := response_body["shellProcessId"]}
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: uni/udb/adapter.icn
Line: 180-184
Comment:
**Sending still uses raw `sock` instead of `json_handler`**
`get_request()` now receives messages through `json_handler` (`JSON_HTTPSocket`), but every response and event is still written by constructing a `"Content-Length: " || len || "\r\n\r\n" || body` string manually and calling `writes(sock, ...)` directly. `JSON_HTTPSocket.send_msg(t)` performs exactly that framing in one place.
Using `json_handler` uniformly for both receive and send would make the transport layer self-contained and reduce the number of places that hand-assemble HTTP-framed messages. For example, `build_response` / `build_event` could return plain tables and let `send_msg` handle serialisation, or the framing could at least delegate to `json_handler.send_msg`.
This is a design suggestion rather than a blocking issue, but the asymmetry means a future framing change still needs to touch multiple methods.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: uni/udb/test_adapter.icn
Line: 1-3
Comment:
**`DAP_TestClient` relies on implicit null-socket initialisation**
`DAP_TestClient` inherits `JSON_HTTPSocket` but does not declare its own `initially`. When `DAP_TestClient()` is called with no arguments (as in `DAP_TestClient().connect(port)`), Unicon invokes the inherited `JSON_HTTPSocket.initially(addr, opt)` with both parameters as `&null`. The `if string(addr)` branch fails, so the else branch executes `sock := &null`, leaving `sock` null until `connect()` overwrites it.
This works today, but adding a no-arg `initially` that skips the parent's socket assignment (or documents the intentional deferred-connect pattern) would make the initialisation path explicit and prevent confusion if the parent's `initially` changes in the future.
How can I resolve this? If you propose a fix, please make it concise.Reviews (4): Last reviewed commit: "udb: fix DAP message handling and JSON-R..." | Re-trigger Greptile |
f34dfdf to
79db724
Compare
Member
|
@greptile review |
Signed-off-by: Joseph Abdo <josephabdo200@gmail.com>
Signed-off-by: Joseph Abdo <josephabdo200@gmail.com>
Signed-off-by: Joseph Abdo <josephabdo200@gmail.com>
Signed-off-by: Joseph Abdo <josephabdo200@gmail.com>
Signed-off-by: Joseph Abdo <josephabdo200@gmail.com>
79db724 to
12d6dd9
Compare
Member
|
@greptile review |
Jafaral
reviewed
Mar 18, 2026
- Refactor test_adapter to reuse JSON_HTTPSocket instead of duplicating socket parsing logic - Implement dynamic message loop - Add test_adapter as a separate executable in Makefile - Link test_adapter with jsonrpc.u - Add explicit build target for test_adapter Signed-off-by: Joseph Abdo <josephabdo200@gmail.com>
- Normalize outbound Content-Length headers to include space after colon - Guard scan subject in launch using \ operator to prevent null string errors - Validate missing 'program' argument and return fail-fast DAP error response Signed-off-by: Joseph Abdo <josephabdo200@gmail.com>
- Fix get_command to correctly fallback to 'event' using \ operator - Remove unused parse method from dap_message - Fix JSON-RPC initially section Signed-off-by: Joseph Abdo <josephabdo200@gmail.com>
Member
|
@greptile review |
Jafaral
reviewed
Mar 23, 2026
Jafaral
reviewed
Mar 23, 2026
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.
No description provided.