{"record":{"id":"916fd84d5ed767f6","repo":"pinpoint-apm/pinpoint","slug":"maxbuckets-should-be-in-1-256-range-916fd8","errorCode":null,"errorMessage":"maxBuckets should be in 1..256 range","messagePattern":"maxBuckets should be in 1\\.\\.256 range","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/wd/RangeOneByteSimpleHash.java","lineNumber":40,"sourceCode":"/**\n * Copy from sematext/HBaseWD\n * Provides handy methods to distribute\n *\n * @author Alex Baranau\n * @author emeroad\n */\npublic class RangeOneByteSimpleHash implements ByteHasher {\n    private static final SaltKey SALT_KEY = ByteSaltKey.SALT;\n\n    protected final int start;\n    protected final int end;\n    private final int mod;\n\n    private final SaltKeyPrefix saltKeyPrefix;\n\n    public RangeOneByteSimpleHash(int start, int end, int maxBuckets) {\n        if (maxBuckets < 1 || maxBuckets > 256) {\n            throw new IllegalArgumentException(\"maxBuckets should be in 1..256 range\");\n        }\n\n        this.start = start;\n        this.end = end;\n        // i.e. \"real\" maxBuckets value = maxBuckets or maxBuckets-1\n        this.mod = maxBuckets;\n\n        this.saltKeyPrefix = new ModSaltKeyPrefix(mod);\n    }\n\n\n    @Override\n    public byte getHashPrefix(byte[] originalKey) {\n        return getHashPrefix(originalKey, 0);\n    }\n\n    @Override\n    public byte getHashPrefix(byte[] originalKey, int saltKeySize) {","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/wd/RangeOneByteSimpleHash.java#L22-L58","documentation":"RangeOneByteSimpleHash hashes one byte of the row key to select one of maxBuckets buckets, so the bucket count must fit in one byte: 1..256. The constructor throws IllegalArgumentException when maxBuckets is outside that range.","triggerScenarios":"Calling new RangeOneByteSimpleHash(start, end, maxBuckets) with maxBuckets < 1 or maxBuckets > 256.","commonSituations":"Hand-written hashing config in Pinpoint's hbase client setup; typo such as 1024 buckets; reading bucket count from an environment-specific config that was edited incorrectly.","solutions":["Use a maxBuckets value between 1 and 256 (commonly 32, 64, or 256).","Validate the value at config-load time before instantiating the hasher.","If more than 256 buckets are needed, switch to a hasher designed for it rather than inflating this one."],"exampleFix":"// before\nHasher hasher = new RangeOneByteSimpleHash(0, 2, 1000);\n// after\nHasher hasher = new RangeOneByteSimpleHash(0, 2, 256);","handlingStrategy":"validation","validationCode":"if (maxBuckets < 1 || maxBuckets > 256) {\n    throw new IllegalArgumentException(\"maxBuckets must be in 1..256, got: \" + maxBuckets);\n}\nHasher hasher = new RangeOneByteSimpleHash(start, end, maxBuckets);","typeGuard":null,"tryCatchPattern":"try {\n    hasher = new RangeOneByteSimpleHash(start, end, maxBuckets);\n} catch (IllegalArgumentException e) {\n    log.error(\"maxBuckets {} out of 1..256\", maxBuckets, e);\n    hasher = new RangeOneByteSimpleHash(start, end, 256);\n}","preventionTips":["Clamp or validate config-driven bucket counts before constructing the hasher.","Remember the one-byte hashing limit: never configure more than 256 buckets for this class.","Cover hasher construction in unit tests fed from real config values."],"tags":["java","configuration","hbase","argument-validation"],"backgroundTag":"value-out-of-range","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"}