{"record":{"id":"a4696e555c688317","repo":"pinpoint-apm/pinpoint","slug":"invalid-metadata-rowkey-length-rowkey-length","errorCode":null,"errorMessage":"invalid metadata rowkey length: ${rowKey.length}","messagePattern":"invalid metadata rowkey length: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/serializer/metadata/MetadataDecoder.java","lineNumber":70,"sourceCode":"\n    private long readAgentStartTime(byte[] rowKey, int offset) {\n        return LongInverter.restore(ByteArrayUtils.bytesToLong(rowKey, offset));\n    }\n\n    private int readId(byte[] rowKey, int offset) {\n        return ByteArrayUtils.bytesToInt(rowKey, offset);\n    }\n\n    private ServiceUid readServiceUid(byte[] rowKey, int offset) {\n        final int remaining = rowKey.length - offset;\n        if (remaining == 0) {\n            return ServiceUid.DEFAULT;\n        } else if (remaining == BytesUtils.INT_BYTE_LENGTH) {\n            ServiceUid serviceUid = ServiceUid.of(ByteArrayUtils.bytesToInt(rowKey, offset));\n            validateServiceUid(serviceUid);\n            return serviceUid;\n        } else {\n            throw new IllegalArgumentException(\"invalid metadata rowkey length: \" + rowKey.length);\n        }\n    }\n\n    private static void validateServiceUid(ServiceUid serviceUid) {\n        if (ServiceUid.ERROR.equals(serviceUid)\n                || ServiceUid.UNKNOWN.equals(serviceUid)) {\n            throw new IllegalArgumentException(\"invalid metadata serviceUid: \" + serviceUid);\n        }\n    }\n}\n","sourceCodeStart":52,"sourceCodeEnd":81,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/serializer/metadata/MetadataDecoder.java#L52-L81","documentation":"MetadataDecoder.readServiceUid parses the serviceUid prefix of a metadata row key, which must be either 0 bytes (default serviceUid) or exactly INT_BYTE_LENGTH (4 bytes). Any other remaining rowKey length means the key layout is invalid, so the decoder throws this IllegalArgumentException.","triggerScenarios":"Decoding a metadata row key whose length is neither 0 nor 4 bytes in the serviceUid region, e.g. a truncated/corrupted HBase row key, a key produced by a different schema version, or an incorrectly constructed key written by custom tooling.","commonSituations":"Reading rows written by an older/newer Pinpoint version whose metadata rowkey layout differs; manual row scans/repairs copying wrong-length keys; applicationName/agentId changes shifting key offsets in hand-built keys.","solutions":["Check the row key length and content before decoding; skip or quarantine malformed keys","Regenerate the row key using the current MetadataRowKey/encoder utilities instead of hand-built byte arrays","Verify data and server versions match the expected metadata rowkey schema; migrate old rows if needed"],"exampleFix":"// before\nServiceUid uid = decoder.readServiceUid(rowKey, offset); // throws for odd lengths\n// after\nint rem = rowKey.length - offset;\nif (rem != 0 && rem != BytesUtils.INT_BYTE_LENGTH) {\n    logger.warn(\"Skipping malformed metadata rowkey length \" + rowKey.length);\n    return; // or use ServiceUid.DEFAULT\n}\nServiceUid uid = decoder.readServiceUid(rowKey, offset);","handlingStrategy":"validation","validationCode":"int remaining = rowKey.length - offset;\nif (remaining != 0 && remaining != BytesUtils.INT_BYTE_LENGTH) {\n    logger.warn(\"Invalid metadata rowkey length \" + rowKey.length);\n    return; // skip malformed row\n}","typeGuard":"boolean hasValidServiceUidRegion(byte[] rowKey, int offset) {\n    int rem = rowKey.length - offset;\n    return rem == 0 || rem == BytesUtils.INT_BYTE_LENGTH;\n}","tryCatchPattern":"try {\n    ServiceUid uid = MetadataDecoder.readServiceUid(rowKey, offset);\n} catch (IllegalArgumentException e) {\n    logger.warn(\"Malformed metadata rowkey: \" + Arrays.toString(rowKey), e);\n    // skip or migrate row\n}","preventionTips":["Build metadata row keys only via the official encoder utilities","Skip/quarantine rows whose key length does not match the expected schema","Align reader and writer versions before scanning metadata tables"],"tags":["java","hbase","rowkey-decoding"],"backgroundTag":"invalid-identifier-format","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"}