{"record":{"id":"96e5fe4f9d7cca9a","repo":"pinpoint-apm/pinpoint","slug":"negative-maxlength-maxlength","errorCode":null,"errorMessage":"negative maxLength:+maxLength","messagePattern":"negative maxLength:\\+maxLength","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"commons/src/main/java/com/navercorp/pinpoint/common/util/IdValidateUtils.java","lineNumber":60,"sourceCode":"        return validateId(id, DEFAULT_MAX_LENGTH);\n    }\n\n    public static boolean validateId(String id, int maxLength) {\n        final CheckResult result = checkId(id, maxLength);\n        return result == CheckResult.SUCCESS;\n    }\n\n    public enum CheckResult {\n        SUCCESS,\n        FAIL_LENGTH,\n        FAIL_PATTERN;\n    }\n\n    public static CheckResult checkId(String id, int maxLength) {\n        Objects.requireNonNull(id, \"id\");\n\n        if (maxLength <= 0) {\n            throw new IllegalArgumentException(\"negative maxLength:\" + maxLength);\n        }\n\n        if (!checkLength(id, maxLength)) {\n            return CheckResult.FAIL_LENGTH;\n        }\n        if (!checkPattern(id)) {\n            return CheckResult.FAIL_PATTERN;\n        }\n        return CheckResult.SUCCESS;\n    }\n\n    public static boolean checkPattern(String id) {\n        final Matcher matcher = ID_PATTERN.matcher(id);\n        return matcher.matches();\n    }\n\n    public static boolean checkLength(String id, int maxLength) {\n        Objects.requireNonNull(id, \"id\");","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/commons/src/main/java/com/navercorp/pinpoint/common/util/IdValidateUtils.java#L42-L78","documentation":"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.","triggerScenarios":"Calling checkId(id, maxLength) with maxLength <= 0, e.g. passing an unset/zero config value for max length or an uninitialized int field.","commonSituations":"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.","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"],"exampleFix":"// before\nCheckResult r = IdValidateUtils.checkId(id, maxLength); // maxLength = 0 from config\n// after\nif (maxLength <= 0) {\n    throw new IllegalArgumentException(\"maxLength must be positive: \" + maxLength);\n}\nCheckResult r = IdValidateUtils.checkId(id, maxLength);","handlingStrategy":"validation","validationCode":"if (maxLength <= 0) throw new IllegalArgumentException(\"maxLength must be > 0: \" + maxLength);\nCheckResult r = IdValidateUtils.checkId(id, maxLength);","typeGuard":"boolean hasValidMaxLength(int maxLength) { return maxLength > 0; }","tryCatchPattern":"try {\n    result = IdValidateUtils.checkId(id, maxLength);\n} catch (IllegalArgumentException e) {\n    logger.warn(\"checkId misused: {}\", e.getMessage());\n    result = CheckResult.FAIL_LENGTH;\n}","preventionTips":["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)"],"tags":["validation","argument-check","pinpoint-commons"],"backgroundTag":"invalid-argument-value","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}