{"record":{"id":"6a07856e2434b9e2","repo":"go-delve/delve","slug":"unknown-target-command","errorCode":null,"errorMessage":"unknown target command","messagePattern":"unknown target command","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/dap/command.go","lineNumber":326,"sourceCode":"\t\tdefer unlock()\n\t\tpid, err := strconv.Atoi(argv[1])\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tfound := false\n\t\tfor _, tgt := range tgrp.Targets() {\n\t\t\tif _, err = tgt.Valid(); err == nil && tgt.Pid() == pid {\n\t\t\t\tfound = true\n\t\t\t\ttgrp.Selected = tgt\n\t\t\t\ttgt.SwitchThread(pid)\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\treturn \"\", fmt.Errorf(\"could not find target %d\", pid)\n\t\t}\n\t\treturn fmt.Sprintf(\"Switched to process %d\", pid), err\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unknown target command\")\n\t}\n}\n","sourceCodeStart":308,"sourceCodeEnd":329,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/service/dap/command.go#L308-L329","documentation":"The 'target' DAP command supports only the subcommands 'list', 'follow-exec', and 'switch'. Anything else in argv[0] falls into the default case and returns this generic error. It indicates the subcommand name itself (not its arguments) is unrecognized.","triggerScenarios":"Evaluating 'target foo', 'target select 1234' (instead of switch), 'target detach', or an empty/garbled command string reaching targetCmd via DAP evaluate.","commonSituations":"Users porting CLI habits from 'dlv' terminal or GDB ('target select', 'detach') into DAP evaluate; frontend constructing 'target <something>' from a dropdown with unsupported actions; whitespace mangling producing an empty subcommand.","solutions":["Use one of: 'target list', 'target follow-exec [-on regex|-off]', 'target switch <pid>'.","Replace GDB-style 'target select <pid>' with 'target switch <pid>'.","Perform actions like detach through the dedicated DAP requests (disconnect/restart) rather than the target command.","Check the exact spelling and that the command string wasn't truncated by your client."],"exampleFix":"// before\ntarget select 4242\n// after\ntarget switch 4242","handlingStrategy":"validation","validationCode":"validSubcommands := map[string]bool{\"list\": true, \"follow-exec\": true, \"switch\": true}\nsub := strings.Fields(cmdStr)\nif len(sub) < 2 || !validSubcommands[sub[1]] {\n    return fmt.Errorf(\"'target' supports only list, follow-exec, switch\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Memorize the three subcommands: list, follow-exec, switch","Translate GDB habits (target select/detach) to switch/dedicated DAP requests","Escape/trim the command string so the subcommand is not empty or mangled"],"tags":["dap","command-args","repl"],"backgroundTag":"unknown-command","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}