{"record":{"id":"430ff6b678e18e42","repo":"alibaba/arthas","slug":"the-line-option-is-required-unless-list-lines","errorCode":null,"errorMessage":"The --line option is required unless --list-lines is used.","messagePattern":"The --line option is required unless --list-lines is used\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"core/src/main/java/com/taobao/arthas/core/command/monitor200/LineCommand.java","lineNumber":274,"sourceCode":"        if (expand == null || expand < 0 || expand > ObjectView.MAX_DEEP) {\n            return \"expand must be between 0 and \" + ObjectView.MAX_DEEP + \".\";\n        }\n        String sizeLimitError = WatchCommand.validateSizeLimit(sizeLimit);\n        if (sizeLimitError != null) {\n            return sizeLimitError;\n        }\n        if (numberOfLimit <= 0) {\n            return \"limits must be greater than 0.\";\n        }\n        if (stackDepth <= 0 || stackDepth > MAX_STACK_DEPTH) {\n            return \"stack-depth must be between 1 and \" + MAX_STACK_DEPTH + \".\";\n        }\n        return null;\n    }\n\n    static Set<Integer> parseLines(List<String> lineSpecs) {\n        if (lineSpecs == null || lineSpecs.isEmpty()) {\n            throw new IllegalArgumentException(\"The --line option is required unless --list-lines is used.\");\n        }\n        Set<Integer> result = new LinkedHashSet<Integer>();\n        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 {","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/core/src/main/java/com/taobao/arthas/core/command/monitor200/LineCommand.java#L256-L292","documentation":"Thrown as IllegalArgumentException by LineCommand.parseLines when lineSpecs is null or empty. parseLines expects at least one line spec; the only way to legally omit --line is to use --list-lines instead. This guard enforces that contract: you must either give explicit line numbers or ask to list them.","triggerScenarios":"Run the line command without --line and without --list-lines, so the line-spec collection passed to parseLines is null/empty. The command cannot proceed because there is no target line to set a breakpoint/inspection on and listing was not requested.","commonSituations":"User forgets --line; assumes a default line is picked; misreads the help and provides neither --line nor --list-lines.","solutions":["Add --line <numbers> (e.g. --line 42 or --line 10,20,30).","Or add --list-lines to enumerate available lines instead of targeting one."],"exampleFix":"// before\nline com.example.Foo\n\n// after\nline com.example.Foo --line 42\n// or\nline com.example.Foo --list-lines","handlingStrategy":"validation","validationCode":"boolean hasLine = lineSpecs != null && !lineSpecs.isEmpty();\nif (!hasLine && !listLinesFlag) {\n    // require either --line or --list-lines before invoking the command\n}","typeGuard":"static boolean hasLineInput(List<String> specs, boolean listLines) {\n    return listLines || (specs != null && !specs.isEmpty());\n}","tryCatchPattern":"try { Set<Integer> lines = LineCommand.parseLines(lineSpecs); } catch (IllegalArgumentException e) { // prompt: add --line N or --list-lines }","preventionTips":["Always pass --line N (or --list-lines) when invoking the line command.","Validate at the CLI/UX layer that one of the two is present.","Surface the mutual-exclusion/default clearly in help text."],"tags":["line-command","user-input","validation","configuration"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}