{"record":{"id":"cf3f1db0f4367b46","repo":"alibaba/arthas","slug":"invalid-line-number","errorCode":null,"errorMessage":"Invalid line number: {}","messagePattern":"Invalid line number: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/com/taobao/arthas/core/command/monitor200/LineCommand.java","lineNumber":295,"sourceCode":"        for (String lineSpec : lineSpecs) {\n            if (StringUtils.isEmpty(lineSpec)) {\n                continue;\n            }\n            String[] parts = lineSpec.split(\",\");\n            for (String part : parts) {\n                String value = part.trim();\n                if (value.length() == 0) {\n                    continue;\n                }\n                if (value.indexOf('-') >= 0) {\n                    throw new IllegalArgumentException(\"Line range syntax is not supported in the first version: \"\n                            + value);\n                }\n                final int lineNumber;\n                try {\n                    lineNumber = Integer.parseInt(value);\n                } catch (NumberFormatException e) {\n                    throw new IllegalArgumentException(\"Invalid line number: \" + value);\n                }\n                if (lineNumber <= 0) {\n                    throw new IllegalArgumentException(\"Line number must be greater than 0: \" + value);\n                }\n                result.add(lineNumber);\n                if (result.size() > MAX_LINE_COUNT) {\n                    throw new IllegalArgumentException(\"Too many line numbers, maximum is \" + MAX_LINE_COUNT + \".\");\n                }\n            }\n        }\n        if (result.isEmpty()) {\n            throw new IllegalArgumentException(\"The --line option is required unless --list-lines is used.\");\n        }\n        return result;\n    }\n\n    private void listLines(CommandProcess process) {\n        try {","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/core/src/main/java/com/taobao/arthas/core/command/monitor200/LineCommand.java#L277-L313","documentation":"Thrown by the `line` command's parseLines() when a `--line` value fails Integer.parseInt (NumberFormatException). Arthas's `line` command watches local variables at specific source line numbers; the `--line` option accepts comma-separated positive integers only. Any token that is not a pure integer is rejected.","triggerScenarios":"Running `line --class demo.MathGame --line abc`, `--line 12x`, `--line 1,foo,3`, or `--line 51;` (trailing punctuation). The offending comma-split part reaches Integer.parseInt and is not numeric.","commonSituations":"Typo in the line number; pasting line numbers copied from an IDE with extra formatting; mixing in a line-range like `51-56` with a malformed token (ranges are also rejected earlier at line 287); leaving a stray comma producing a non-numeric part such as `51,,53` is tolerated, but `51,a` is not.","solutions":["Supply only comma-separated positive integers, e.g. `--line 51,56,60`.","Strip any non-digit characters from the --line value before running.","If you wanted a range, list each line explicitly since range syntax is unsupported.","Use `--list-lines --class <FQN>` first to discover valid line numbers."],"exampleFix":"// before\nline --class demo.MathGame --line 51,56a\n// after\nline --class demo.MathGame --line 51,56","handlingStrategy":"validation","validationCode":"// Validate --line spec before invoking the line command\nstatic boolean isValidLineSpec(String spec) {\n    if (spec == null || spec.trim().isEmpty()) return false;\n    for (String part : spec.split(\",\")) {\n        String v = part.trim();\n        if (v.isEmpty()) continue;\n        if (v.indexOf('-') >= 0) return false;          // range syntax unsupported\n        try { Integer.parseInt(v); } catch (NumberFormatException e) { return false; }\n    }\n    return true;\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Pre-validate each comma-separated --line token is a pure positive integer.","Generate line specs from tooling rather than typing them by hand.","Run `line --list-lines --class <FQN>` to discover valid line numbers first."],"tags":["arthas","line-command","input-validation","cli"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}