Skip to content

Commit aaea9fe

Browse files
committed
fix(dap): validate attach_endpoint's arguments up front
The helper dereferences config.port/host and opts.label/default_port; a malformed call (nil opts, missing label) crashed with a low-level "attempt to index" instead of an actionable message. Assert both shapes at the top — same clear-config-time-error purpose the function exists for, matching M.resolve's spec.configure assert precedent. Verified: the two internal callers (delve, python) still pass; nil/label-less calls now error clearly.
1 parent 7d143b1 commit aaea9fe

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

lua/modules/utils/dap.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ end
3030
---@param opts { label: string, default_port?: integer } @default_port omitted = port required.
3131
---@return string host, integer port
3232
function M.attach_endpoint(config, opts)
33+
-- Actionable config-time errors beat an opaque "attempt to index" deeper in
34+
-- (this helper's whole purpose): guard the two shapes it dereferences.
35+
assert(type(config) == "table", "attach_endpoint: config must be a table")
36+
assert(type(opts) == "table" and type(opts.label) == "string", "attach_endpoint: opts.label (string) is required")
3337
local port = opts.default_port
3438
if config.port ~= nil then
3539
local n = tonumber(config.port)

0 commit comments

Comments
 (0)