pinpoint-apm/pinpoint · error · IllegalArgumentException
negative maxLength:+maxLength
Error message
negative maxLength:+maxLength
What it means
IdValidateUtils.checkId validates agent/application ID strings for length and pattern. The library throws IllegalArgumentException when the maxLength argument is zero or negative, because a non-positive length limit makes validation meaningless. This is a caller programming error, not a data problem with the id itself.
Solutions
- Check that the maxLength config value is set and > 0 before calling checkId
- Fix the default value so it is a positive number (e.g. 24)
- Validate the parsed config integer and fail fast at startup if <= 0
Example fix
// before
CheckResult r = IdValidateUtils.checkId(id, maxLength); // maxLength = 0 from config
// after
if (maxLength <= 0) {
throw new IllegalArgumentException("maxLength must be positive: " + maxLength);
}
CheckResult r = IdValidateUtils.checkId(id, maxLength); Defensive patterns
Strategy: validation
Validate before calling
if (maxLength <= 0) throw new IllegalArgumentException("maxLength must be > 0: " + maxLength);
CheckResult r = IdValidateUtils.checkId(id, maxLength); Type guard
boolean hasValidMaxLength(int maxLength) { return maxLength > 0; } Try / catch
try {
result = IdValidateUtils.checkId(id, maxLength);
} catch (IllegalArgumentException e) {
logger.warn("checkId misused: {}", e.getMessage());
result = CheckResult.FAIL_LENGTH;
} Prevention
- Never pass raw config ints as maxLength without a positive-value check
- Avoid -1 as an 'unlimited' sentinel; it is rejected here
- Unit-test validators with boundary maxLength values (0, 1)
When it happens
Trigger: Calling checkId(id, maxLength) with maxLength <= 0, e.g. passing an unset/zero config value for max length or an uninitialized int field.
Common situations: Configuration property for max ID length missing or parsed as 0; passing -1 as a sentinel 'unlimited'; copying a default value of 0 from an uninitialized builder.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- cannot round to nearest multiple of values less than 1
- negative maxWidth:+maxWidth
- num cannot be negative
- agentInfoRefreshIntervalMs must be greater than 0
- agentInfoSendIntervalMs must be greater than 0
AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07).
Data as JSON: /api/errors/96e5fe4f9d7cca9a.
Report an issue: GitHub.
Appendix: source
Thrown at commons/src/main/java/com/navercorp/pinpoint/common/util/IdValidateUtils.java:60
return validateId(id, DEFAULT_MAX_LENGTH);
}
public static boolean validateId(String id, int maxLength) {
final CheckResult result = checkId(id, maxLength);
return result == CheckResult.SUCCESS;
}
public enum CheckResult {
SUCCESS,
FAIL_LENGTH,
FAIL_PATTERN;
}
public static CheckResult checkId(String id, int maxLength) {
Objects.requireNonNull(id, "id");
if (maxLength <= 0) {
throw new IllegalArgumentException("negative maxLength:" + maxLength);
}
if (!checkLength(id, maxLength)) {
return CheckResult.FAIL_LENGTH;
}
if (!checkPattern(id)) {
return CheckResult.FAIL_PATTERN;
}
return CheckResult.SUCCESS;
}
public static boolean checkPattern(String id) {
final Matcher matcher = ID_PATTERN.matcher(id);
return matcher.matches();
}
public static boolean checkLength(String id, int maxLength) {
Objects.requireNonNull(id, "id");View on GitHub (pinned to 744c3d3075)