{"record":{"id":"26f86f23803b119a","repo":"pinpoint-apm/pinpoint","slug":"limit-must-be-positive-or-1-unlimited-limit","errorCode":null,"errorMessage":"limit must be positive or -1(unlimited): <limit>","messagePattern":"limit must be positive or -1\\(unlimited\\): <limit>","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/bo/ColumnGetCount.java","lineNumber":38,"sourceCode":"import org.apache.hadoop.hbase.filter.ColumnCountGetFilter;\nimport org.apache.hadoop.hbase.filter.Filter;\n\n/**\n * @author Taejin Koo\n */\npublic class ColumnGetCount {\n\n    public static final int UNLIMITED_COUNT = Integer.MAX_VALUE;\n    public static final ColumnGetCount UNLIMITED_COLUMN_GET_COUNT = new ColumnGetCount(UNLIMITED_COUNT);\n\n    private final int limit;\n\n    public static ColumnGetCount of(int limit) {\n        if (limit == -1 || limit == UNLIMITED_COUNT) {\n            return ColumnGetCount.UNLIMITED_COLUMN_GET_COUNT;\n        }\n        if (limit <= 0) {\n            throw new IllegalArgumentException(\"limit must be positive or -1(unlimited): \" + limit);\n        }\n        return new ColumnGetCount(limit);\n    }\n\n    ColumnGetCount(int limit) {\n        Assert.isTrue(limit > 0, \"limit must be 'limit >= 0'\");\n        this.limit = limit;\n    }\n\n    public int getLimit() {\n        return limit;\n    }\n\n    public boolean isReachedLimit(int resultSize) {\n        if (limit == UNLIMITED_COUNT) {\n            return false;\n        }\n        return resultSize >= limit;","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/bo/ColumnGetCount.java#L20-L56","documentation":"ColumnGetCount.of validates the column fetch limit: -1 (or the UNLIMITED_COUNT sentinel) maps to an unlimited singleton, but any other value must be strictly positive. Zero or other negatives are rejected with IllegalArgumentException because they are not meaningful limits for HBase gets.","triggerScenarios":"Calling ColumnGetCount.of(0) or of(-2), often from code that treats 0 as 'no limit' or -1/-2 as sentinels from configuration parsing.","commonSituations":"Config properties for max column count parsed to 0 when unset; callers passing -1 variants (e.g. -2 from a different sentinel convention) expecting unlimited semantics.","solutions":["Pass limit >= 1 for a bounded get, or exactly -1 for unlimited","Fix the config/property parsing that produced 0 and map 'unset' to -1 instead","Guard at the call site: use limit <= 0 ? ColumnGetCount.UNLIMITED_COLUMN_GET_COUNT : ColumnGetCount.of(limit) only if that matches your intent"],"exampleFix":"// before\nColumnGetCount.of(maxColumns); // maxColumns=0 from unset property\n// after\nColumnGetCount.of(maxColumns <= 0 ? -1 : maxColumns);","handlingStrategy":"validation","validationCode":"int safeLimit = (limit == -1 || limit <= 0) ? -1 : limit;\nColumnGetCount count = ColumnGetCount.of(safeLimit); // -1 => unlimited","typeGuard":null,"tryCatchPattern":"try {\n    return ColumnGetCount.of(rawLimit);\n} catch (IllegalArgumentException e) {\n    logger.warn(\"Invalid column limit {}, defaulting to unlimited\", rawLimit);\n    return ColumnGetCount.UNLIMITED_COLUMN_GET_COUNT;\n}","preventionTips":["Normalize config defaults: unset max-column-count => -1, not 0","Validate numeric properties at startup","Document the -1-unlimited sentinel convention for your team"],"tags":["hbase","argument-validation","limit"],"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-14T05:17:10.506Z"}