zaproxy/zaproxy · warning
Attempt to addParameters(null) ignored
Error message
Attempt to addParameters(null) ignored
What it means
GenericMethod.addParameters(NameValuePair[]) logs a warning and returns without modifying the request body when handed a null array. The call is otherwise a no-op-safe defensive guard inherited from PostMethod-style semantics; the request body is simply left unchanged (or empty for a fresh method).
Source
Thrown at zap/src/main/java/org/parosproxy/paros/network/GenericMethod.java:269
if (param == null) {
throw new IllegalArgumentException("NameValuePair may not be null");
}
addParameter(param.getName(), param.getValue());
}
/**
* Adds an array of parameters to be used in the POST request body. Logs a
* warning if the parameters argument is null.
*
* @param parameters The array of parameters to add.
*
* @since 2.0
*/
public void addParameters(NameValuePair[] parameters) {
log.trace("enter PostMethod.addParameters(NameValuePair[])");
if (parameters == null) {
log.warn("Attempt to addParameters(null) ignored");
} else {
super.clearRequestBody();
for (int i = 0; i < parameters.length; i++) {
this.params.add(parameters[i]);
}
}
}
/**
* Removes all parameters with the given paramName. If there is more than
* one parameter with the given paramName, all of them are removed. If
* there is just one, it is removed. If there are none, then the request
* is ignored.
*
* @param paramName The parameter name to remove.
*
* @return true if at least one parameter was removed
*View on GitHub (pinned to 9d1970a436)
Solutions
- Pass an empty NameValuePair[] instead of null if you intend to clear/initialize form parameters.
- Null-check or default your parameters collection before calling addParameters.
- If a null body is expected, skip the addParameters call entirely and set the body explicitly.
Example fix
// before
method.addParameters(params); // params may be null
// after
if (params != null) {
method.addParameters(params);
} Defensive patterns
Strategy: validation
Validate before calling
if (parameters == null) {
parameters = new NameValuePair[0];
}
method.addParameters(parameters); Prevention
- Initialize parameter collections eagerly (empty, not null).
- Centralize request building in one helper that normalizes null to empty arrays.
- Enable trace logging on org.parosproxy.paros.network when debugging request bodies.
When it happens
Trigger: Calling method.addParameters(null) directly, or calling setRequestBody(Object body)/setRequestBody(String) on a GenericMethod where the body is null and the method routes to addParameters for form-encoded bodies.
Common situations: Building form POST requests where the parameters map/array was never populated (e.g. a form with no fields), refactoring code that used to pass an empty array, deserializing request specs where parameters are optional and null is passed straight through.
Related errors
- Connection is open
- Connection is not open
- Invalid uri '<uri>': <uriExceptionMessage>
- Content too large to be buffered: <contentLength> bytes
- maxlen must be positive
AI-assisted analysis of zaproxy/zaproxy@9d1970a436 (2026-09-05).
Data as JSON: /api/errors/7064013fb5155a77.
Report an issue: GitHub.