apache/rocketmq · error · AuthorizationException
is null.
Error message
is null.
What it means
Produced by decodeRequiredBody when the remoting command's body is null or zero-length: it throws AuthorizationException(bodyName + " is null.") so the caller sees e.g. 'topic list is null.', 'subscription group list is null.', or 'topic queue mapping is null.'. It guards every admin request code that needs a serialized body object (UPDATE_AND_CREATE_TOPIC_LIST, ..._SUBSCRIPTIONGROUP_LIST, UPDATE_AND_CREATE_STATIC_TOPIC, DELETE_TOPIC_IN_BROKER_LIST, DELETE_SUBSCRIPTION_GROUP_LIST, etc.) before attempting to decode.
Source
Thrown at auth/src/main/java/org/apache/rocketmq/auth/authorization/builder/DefaultAuthorizationContextBuilder.java:622
break;
}
if (CollectionUtils.isNotEmpty(result)) {
result.forEach(r -> {
r.setChannelId(context.channel().id().asLongText());
r.setRpcCode(String.valueOf(command.getCode()));
});
}
} catch (AuthorizationException ex) {
throw ex;
} catch (Throwable t) {
throw new AuthorizationException("parse authorization context error.", t);
}
return result;
}
private static <T> T decodeRequiredBody(RemotingCommand command, Class<T> bodyClass, String bodyName) {
if (command.getBody() == null || command.getBody().length == 0) {
throw new AuthorizationException(bodyName + " is null.");
}
T body = RemotingSerializable.decode(command.getBody(), bodyClass);
if (body == null) {
throw new AuthorizationException(bodyName + " is null.");
}
return body;
}
private static String decodeRequiredText(RemotingCommand command, String bodyName) {
if (command.getBody() == null || command.getBody().length == 0) {
throw new AuthorizationException(bodyName + " is null.");
}
return new String(command.getBody(), StandardCharsets.UTF_8);
}
private static String requireResource(String resource, String resourceName) {
if (StringUtils.isBlank(resource)) {
throw new AuthorizationException(resourceName + " is null.");View on GitHub (pinned to 293f588571)
Solutions
- Serialize the request object (RemotingSerializable.encode) and call command.setBody(bytes) before sending.
- Add a client-side assert that getBody() is non-null and length > 0 for body-carrying request codes.
- Use the high-level admin APIs which always attach the body.
Example fix
// before RemotingCommand cmd = RemotingCommand.createRequestCommand(code, header); // body never set -> 'topic list is null.' // after RemotingCommand cmd = RemotingCommand.createRequestCommand(code, header); cmd.setBody(RemotingSerializable.encode(requestBody));
Defensive patterns
Strategy: validation
Validate before calling
if (requestBody != null) {
byte[] body = RemotingSerializable.encode(requestBody);
if (body != null && body.length > 0) cmd.setBody(body);
} Try / catch
try { client.invokeSync(addr, cmd, timeout); }
catch (AuthorizationException e) {
if (e.getMessage().endsWith("is null.") && cmd.getBody() == null) { attachBodyAndResend(); return; }
throw e;
} Prevention
- Always call setBody for body-carrying request codes
- Assert getBody() is non-empty before invoke
- Use high-level admin APIs
When it happens
Trigger: Sending any of the list/static-topic admin request codes without calling RemotingCommand#setBody, or with a zero-byte array. Common when a client constructs the request header correctly but forgets to serialize and attach the body object.
Common situations: Custom admin tooling or test harnesses that build RemotingCommand manually; refactors that drop the setBody call; clients assuming the broker fills in a default body.
Related errors
- topic config is null.
- subscription group is null.
- subscription group config is null.
- User:{} is not found
- topic list is empty.
AI-assisted analysis of apache/rocketmq@293f588571 (2026-08-14).
Data as JSON: /api/errors/c2d988bb2d51910c.
Report an issue: GitHub.