{"record":{"id":"9f9773b57c554d0f","repo":"go-delve/delve","slug":"count-len-must-be-a-positive-integer","errorCode":null,"errorMessage":"count/len must be a positive integer","messagePattern":"count/len must be a positive integer","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/api/command.go","lineNumber":244,"sourceCode":"\t\t\t\t\t\"dec\":         'd',\n\t\t\t\t\t\"decimal\":     'd',\n\t\t\t\t\t\"bin\":         'b',\n\t\t\t\t\t\"binary\":      'b',\n\t\t\t\t}\n\t\t\t\tout.Format, ok = fmtMapToPriFmt[arg]\n\t\t\t\tif !ok {\n\t\t\t\t\treturn nil, fmt.Errorf(\"%q is not a valid format\", arg)\n\t\t\t\t}\n\t\t\t}\n\t\tcase \"-count\", \"-len\":\n\t\t\targ := nextArg()\n\t\t\tif arg == \"\" {\n\t\t\t\treturn nil, errors.New(\"expected argument after -count/-len\")\n\t\t\t}\n\t\t\tvar err error\n\t\t\tout.Count, err = strconv.ParseInt(arg, 0, 64)\n\t\t\tif err != nil || out.Count <= 0 {\n\t\t\t\treturn nil, errors.New(\"count/len must be a positive integer\")\n\t\t\t}\n\t\tcase \"-size\":\n\t\t\targ := nextArg()\n\t\t\tif arg == \"\" {\n\t\t\t\treturn nil, errors.New(\"expected argument after -size\")\n\t\t\t}\n\t\t\tvar err error\n\t\t\tout.Size, err = strconv.ParseInt(arg, 0, 64)\n\t\t\tif err != nil || out.Size <= 0 || out.Size > 8 {\n\t\t\t\treturn nil, errors.New(\"size must be a positive integer (<=8)\")\n\t\t\t}\n\t\tcase \"-x\":\n\t\t\tout.IsExpr = true\n\t\t\t// remaining args are going to be interpreted as expression\n\t\t\tout.Operand = strings.Join(args, \" \")\n\t\t\tbreak loop\n\t\tdefault:\n\t\t\tif len(args) > 0 {","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/service/api/command.go#L226-L262","documentation":"ParseExamineMemoryArg parses the arguments of the DAP `examineMemory`/`x` command. The `-count`/`-len` flag specifies how many memory chunks to read, and it must parse as an integer (base 0, so hex/0x allowed) strictly greater than zero. Delve throws this error when the argument is missing, non-numeric, or <= 0.","triggerScenarios":"Calling the `examineMemory` (aliases `x`) DAP command with `-count <bad>` or `-len <bad>` where the value is empty (caught earlier), not a number (e.g. `-count abc`, `-count 1_000`), or zero/negative (`-count 0`, `-count -5`).","commonSituations":"IDE clients computing the count from a UI field that allows 0; users habituated to other tools' `x` command which defaults or allows 0; copy-pasting counts with unit suffixes like `64b`; negative counts from reversed sign in generated clients.","solutions":["Pass a positive integer for -count/-len, e.g. `x -count 20 -size 8 0xc000010000`","Remember base-0 parsing accepts 0x-prefixed hex; verify the value has no stray characters or suffixes","Omit -count entirely if a default count is acceptable instead of passing 0"],"exampleFix":"// before\n\"x -count 0 -size 8 0xc000010000\"\n// after\n\"x -count 16 -size 8 0xc000010000\"","handlingStrategy":"validation","validationCode":"func validCount(v string) bool {\n\tn, err := strconv.ParseInt(v, 0, 64)\n\treturn err == nil && n > 0\n}\nif !validCount(countArg) { /* fix or prompt before calling examineMemory */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp count to >= 1 before building the command","Parse with base 0 on the client side to mirror Delve","Reject empty strings instead of sending them"],"tags":["dap","argument-parsing","cli"],"backgroundTag":"invalid-argument-value","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}