apache/hadoop · error · HadoopIllegalArgumentException
-protocol needs one parameter
Error message
-protocol needs one parameter
What it means
-protocol consumes exactly one following parameter, the scheme name. parseProtocolArgs checks index+1 >= args.length and throws HadoopIllegalArgumentException('-protocol needs one parameter') when -protocol is the last token, i.e., the scheme value is missing. Parsing aborts before the scheme is ever inspected for validity.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java:218
"-setlevel needs three parameters");
}
operation = Operations.SETLEVEL;
hostName = args[index+1];
className = args[index+2];
level = args[index+3];
return index+4;
}
private int parseProtocolArgs(String[] args, int index) throws
HadoopIllegalArgumentException {
// make sure only -protocol is specified
if (protocol != null) {
throw new HadoopIllegalArgumentException(
"Redundant -protocol command");
}
// check number of arguments is sufficient
if (index+1 >= args.length) {
throw new HadoopIllegalArgumentException(
"-protocol needs one parameter");
}
// check protocol is valid
protocol = args[index+1];
if (!isValidProtocol(protocol)) {
throw new HadoopIllegalArgumentException(
"Invalid protocol: " + protocol);
}
return index+2;
}
/**
* Send HTTP/HTTPS request to get log level.
*
* @throws HadoopIllegalArgumentException if arguments are invalid.
* @throws Exception if unable to connect
*/
private void doGetLevel() throws Exception {View on GitHub (pinned to 2add963021)
Solutions
- Follow -protocol with exactly one value: http or https.
- Default the scheme variable in scripts ('${SCHEME:-http}') so the flag never dangles.
- Omit -protocol entirely when plain http is acceptable — it is the default.
Example fix
# before hadoop loglevel -getlevel nn:9871 cls -protocol # after hadoop loglevel -getlevel nn:9871 cls -protocol https
Defensive patterns
Strategy: validation
Validate before calling
int i = Arrays.asList(args).indexOf("-protocol");
if (i >= 0 && i + 1 >= args.length) {
throw new HadoopIllegalArgumentException("-protocol needs a value: http or https");
} Prevention
- Always follow -protocol immediately with its value.
- Use '${SCHEME:-http}' style defaults in scripts so the flag never dangles.
- Drop -protocol entirely when http is fine.
When it happens
Trigger: 'hadoop loglevel -getlevel h c -protocol' with nothing after the flag; shell variable holding the scheme expanding to empty so the flag ends the command; line breaks splitting the flag from its value in a pasted script.
Common situations: Truncated copy-paste; unquoted/empty scheme variables in automation; heredocs or line continuations losing the trailing token.
Related errors
- -getlevel needs two parameters
- -setlevel needs three parameters
- Redundant -protocol command
- "Invalid protocol: " + protocol
- Expect either -getlevel or -setlevel
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/ec7980b6d5ca6b3c.
Report an issue: GitHub.