{"record":{"id":"eee83789825be92b","repo":"go-delve/delve","slug":"you-must-specify-a-thread","errorCode":null,"errorMessage":"you must specify a thread","messagePattern":"you must specify a thread","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/terminal/command.go","lineNumber":849,"sourceCode":"\t\t}\n\t\tprefix := \"  \"\n\t\tif state.CurrentThread != nil && state.CurrentThread.ID == th.ID {\n\t\t\tprefix = \"* \"\n\t\t}\n\t\tif th.Function != nil {\n\t\t\tfmt.Fprintf(t.stdout, \"%sThread %d at %#v %s:%d %s\\n\",\n\t\t\t\tprefix, th.ID, th.PC, t.formatPath(th.File),\n\t\t\t\tth.Line, th.Function.Name())\n\t\t} else {\n\t\t\tfmt.Fprintf(t.stdout, \"%sThread %s\\n\", prefix, t.formatThread(th))\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc thread(t *Term, ctx callContext, args string) error {\n\tif len(args) == 0 {\n\t\treturn errors.New(\"you must specify a thread\")\n\t}\n\ttid, err := strconv.Atoi(args)\n\tif err != nil {\n\t\treturn err\n\t}\n\toldState, err := t.client.GetState()\n\tif err != nil {\n\t\treturn err\n\t}\n\tnewState, err := t.client.SwitchThread(tid)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\toldThread := \"<none>\"\n\tnewThread := \"<none>\"\n\tif oldState.CurrentThread != nil {\n\t\toldThread = strconv.Itoa(oldState.CurrentThread.ID)","sourceCodeStart":831,"sourceCodeEnd":867,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/terminal/command.go#L831-L867","documentation":"The 'thread' command requires a numeric thread ID argument; this error is returned when it is invoked with no argument. Delve cannot switch threads without knowing which one to target.","triggerScenarios":"Typing 'thread' alone at the (dlv) prompt instead of 'thread <tid>'.","commonSituations":"Habit from other debuggers where 'thread' lists or selects interactively; forgetting the ID after checking 'threads'.","solutions":["Run 'threads' first to list available thread IDs","Use 'thread <id>' with a numeric ID, e.g. 'thread 3'","Use 'goroutine <n>' if you actually meant to switch goroutines"],"exampleFix":"// before\n(dlv) thread\n// after\n(dlv) threads\n(dlv) thread 5","handlingStrategy":"validation","validationCode":"// Ensure a numeric thread id is provided\nparts := strings.Fields(args)\nif len(parts) != 1 {\n    return errors.New(\"usage: thread <tid>\")\n}\nif _, err := strconv.Atoi(parts[0]); err != nil {\n    return fmt.Errorf(\"thread id must be an integer: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"err := term.ExecuteCommand(\"thread \" + args)\nif err != nil && strings.Contains(err.Error(), \"you must specify a thread\") {\n    // list threads and prompt for an id\nst, _ := client.ListThreads()\n    printThreadChoices(st)\n}","preventionTips":["Run 'threads' before switching to know valid IDs","Remember 'thread' requires an ID; it does not list threads","Use 'goroutine <n>' when you mean goroutines, not OS threads"],"tags":["terminal","thread","cli"],"backgroundTag":"missing-required-argument","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}