{"record":{"id":"2aa54cff079b1a07","repo":"go-delve/delve","slug":"bad-arguments-w","errorCode":null,"errorMessage":"bad arguments: %w","messagePattern":"bad arguments: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/dap/command.go","lineNumber":163,"sourceCode":"\t\tif idx := strings.Index(h, \"\\n\"); idx >= 0 {\n\t\t\th = h[:idx]\n\t\t}\n\t\tif len(cmd.aliases) > 1 {\n\t\t\tfmt.Fprintf(&buf, \"    dlv %s (alias: %s) \\t %s\\n\", cmd.aliases[0], strings.Join(cmd.aliases[1:], \" | \"), h)\n\t\t} else {\n\t\t\tfmt.Fprintf(&buf, \"    dlv %s \\t %s\\n\", cmd.aliases[0], h)\n\t\t}\n\t}\n\n\tfmt.Fprintln(&buf)\n\tfmt.Fprintln(&buf, \"Type 'dlv help' followed by a command for full documentation.\")\n\treturn buf.String(), nil\n}\n\nfunc (s *Session) examineMemory(goid, frame int, argstr string) (string, error) {\n\targs, err := api.ParseExamineMemoryArg(argstr)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"bad arguments: %w\", err).Error(), nil\n\t}\n\n\tvar address uint64\n\n\tif args.IsExpr {\n\t\tval, err := s.debugger.EvalVariableInScope(int64(goid), frame, 0, args.Operand, s.loadConfig())\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\n\t\tswitch val.Kind {\n\t\tcase reflect.Pointer: // \"-x &myVar\" or \"-x myPtrVar\"\n\t\t\tif len(val.Children) < 1 {\n\t\t\t\treturn fmt.Errorf(\"bug? invalid pointer: %#v\", val).Error(), nil\n\t\t\t}\n\t\t\taddress = val.Children[0].Addr\n\n\t\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: // \"-x 0xc000079f20 + 8\" or -x 824634220320 + 8","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/service/dap/command.go#L145-L181","documentation":"examineMemory in the DAP session wraps any error returned by api.ParseExamineMemoryArg with the prefix 'bad arguments:'. It indicates the -x/-fmt/-count option string supplied to the examineMemory DAP command failed parsing; the underlying cause (e.g. invalid format or unknown option) follows the prefix.","triggerScenarios":"Sending a DAP REPL or custom 'examineMemory' request whose argstr contains a malformed option string, e.g. argstr=\"-fmt float 0xc000010000\" or an empty/-only option string.","commonSituations":"IDE clients constructing the option string programmatically with wrong flags; user typos in a debug console; API version changes to accepted option names.","solutions":["Read the wrapped cause after 'bad arguments:' and fix that specific option (format name, flag spelling, count value).","Use documented options only: -fmt/-format, -count/-len, -x.","Validate the option string client-side before sending the DAP request."],"exampleFix":"// before\nawait session.customRequest(\"examineMemory\", {argstr: \"-fmt float 0xc000010000\"})\n// after\nawait session.customRequest(\"examineMemory\", {argstr: \"-fmt hex 0xc000010000\"})","handlingStrategy":"validation","validationCode":"var validOpts = map[string]bool{\"-fmt\": true, \"-format\": true, \"-count\": true, \"-len\": true, \"-x\": true}\nfunc argsLookValid(argstr string) bool {\n\tfor _, f := range strings.Fields(argstr) {\n\t\tif strings.HasPrefix(f, \"-\") && !validOpts[f] { return false }\n\t}\n\treturn true\n}","typeGuard":null,"tryCatchPattern":"out, err := s.examineMemory(goid, frame, argstr)\nif err != nil || strings.HasPrefix(out, \"bad arguments:\") {\n\tlog.Printf(\"examine-memory args rejected: %s\", out)\n}","preventionTips":["Build argstr from fixed option constants, not raw user input","Parse the underlying cause after the 'bad arguments:' prefix","Mirror api.ParseExamineMemoryArg validation client-side"],"tags":["dap","argument-parsing","memory-inspection","delve"],"backgroundTag":"invalid-command-flag","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}