{"record":{"id":"0d99787b13646528","repo":"alibaba/arthas","slug":"line-number-must-be-greater-than-0","errorCode":null,"errorMessage":"Line number must be greater than 0: {}","messagePattern":"Line number must be greater than 0: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/com/taobao/arthas/core/command/monitor200/LineCommand.java","lineNumber":298,"sourceCode":"            }\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 {\n            Instrumentation instrumentation = process.session().getInstrumentation();\n            Set<Class<?>> classes = GlobalOptions.isDisableSubClass\n                    ? SearchUtils.searchClass(instrumentation, getClassNameMatcher())","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/core/src/main/java/com/taobao/arthas/core/command/monitor200/LineCommand.java#L280-L316","documentation":"Thrown by parseLines() in the `line` command when the parsed line number is <= 0. Source line numbers are 1-based, so 0 (and any non-positive value that survived parseInt) is invalid. Note that negative literals like `-5` are intercepted earlier as 'range syntax' because they contain a dash.","triggerScenarios":"Running `line --class demo.MathGame --line 0` or `--line 51,0`. The value parses to an integer successfully but fails the `lineNumber <= 0` guard.","commonSituations":"Assuming 0-based line indexing; passing a computed/variable line index that defaulted to 0; copy-paste error where a placeholder 0 was never replaced.","solutions":["Use line numbers >= 1; source lines are 1-indexed.","Run `line --list-lines --class <FQN>` to see the smallest valid line number for the class.","If scripting, clamp or reject 0 before passing to --line."],"exampleFix":"// before\nline --class demo.MathGame --line 0\n// after\nline --class demo.MathGame --line 51","handlingStrategy":"validation","validationCode":"static Integer parseLineOrThrow(String raw) {\n    int n = Integer.parseInt(raw.trim());   // NumberFormatException handled separately\n    if (n <= 0) throw new IllegalArgumentException(\"line must be > 0: \" + raw);\n    return n;\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Remember source line numbers are 1-based.","Clamp computed line indices to >= 1 before passing to --line."],"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"}