alibaba/arthas · warning · IllegalArgumentException
The --line option is required unless --list-lines is used.
Error message
The --line option is required unless --list-lines is used.
What it means
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.
Source
Thrown at core/src/main/java/com/taobao/arthas/core/command/monitor200/LineCommand.java:274
if (expand == null || expand < 0 || expand > ObjectView.MAX_DEEP) {
return "expand must be between 0 and " + ObjectView.MAX_DEEP + ".";
}
String sizeLimitError = WatchCommand.validateSizeLimit(sizeLimit);
if (sizeLimitError != null) {
return sizeLimitError;
}
if (numberOfLimit <= 0) {
return "limits must be greater than 0.";
}
if (stackDepth <= 0 || stackDepth > MAX_STACK_DEPTH) {
return "stack-depth must be between 1 and " + MAX_STACK_DEPTH + ".";
}
return null;
}
static Set<Integer> parseLines(List<String> lineSpecs) {
if (lineSpecs == null || lineSpecs.isEmpty()) {
throw new IllegalArgumentException("The --line option is required unless --list-lines is used.");
}
Set<Integer> result = new LinkedHashSet<Integer>();
for (String lineSpec : lineSpecs) {
if (StringUtils.isEmpty(lineSpec)) {
continue;
}
String[] parts = lineSpec.split(",");
for (String part : parts) {
String value = part.trim();
if (value.length() == 0) {
continue;
}
if (value.indexOf('-') >= 0) {
throw new IllegalArgumentException("Line range syntax is not supported in the first version: "
+ value);
}
final int lineNumber;
try {View on GitHub (pinned to 21cf2e9ba5)
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.
Example fix
// before line com.example.Foo // after line com.example.Foo --line 42 // or line com.example.Foo --list-lines
Defensive patterns
Strategy: validation
Validate before calling
boolean hasLine = lineSpecs != null && !lineSpecs.isEmpty();
if (!hasLine && !listLinesFlag) {
// require either --line or --list-lines before invoking the command
} Type guard
static boolean hasLineInput(List<String> specs, boolean listLines) {
return listLines || (specs != null && !specs.isEmpty());
} Try / catch
try { Set<Integer> lines = LineCommand.parseLines(lineSpecs); } catch (IllegalArgumentException e) { // prompt: add --line N or --list-lines } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: User forgets --line; assumes a default line is picked; misreads the help and provides neither --line nor --list-lines.
Related errors
- '{s}' is not a valid size. Should be numeric value followed
- '{s}' is not a valid timespan. Shoule be numeric value follo
- {optionName} must not be blank.
- {optionName} must be greater than 0.
- {optionName} is invalid: {value}
AI-assisted analysis of alibaba/arthas@21cf2e9ba5 (2026-08-14).
Data as JSON: /api/errors/430ff6b678e18e42.
Report an issue: GitHub.