{"record":{"id":"60c6276698eee86a","repo":"pinpoint-apm/pinpoint","slug":"sqluid-length-must-be-16-sqluid-length","errorCode":null,"errorMessage":"sqlUid length must be 16: ${sqlUid.length}","messagePattern":"sqlUid length must be 16: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/SqlUidMetaDataBo.java","lineNumber":55,"sourceCode":"    private final byte[] sqlUid;\n    @NonNull\n    private final String sql;\n\n    // used by web only\n    public SqlUidMetaDataBo(ServiceUid serviceUid, String agentId, long startTime, byte[] sqlUid, String sql) {\n        this(serviceUid, agentId, startTime, \"\", sqlUid, sql);\n    }\n\n    public SqlUidMetaDataBo(ServiceUid serviceUid, String agentId, long startTime, String applicationName, byte[] sqlUid, String sql) {\n        this.serviceUid = Objects.requireNonNull(serviceUid, \"serviceUid\");\n        this.agentId = StringPrecondition.requireHasLength(agentId, \"agentId\");\n        this.startTime = NumberPrecondition.requirePositiveOrZero(startTime, \"startTime\");\n        this.applicationName = Objects.requireNonNull(applicationName, \"applicationName\");\n        this.sqlUid = Objects.requireNonNull(sqlUid, \"sqlUid\");\n        this.sql = Objects.requireNonNull(sql, \"sql\");\n\n        if (sqlUid.length != UidMetaDataRowKey.UID_LENGTH) {\n            throw new IllegalArgumentException(\"sqlUid length must be 16: \" + sqlUid.length);\n        }\n    }\n\n    @Override\n    public ServiceUid getServiceUid() {\n        return serviceUid;\n    }\n\n    @Override\n    public String getAgentId() {\n        return agentId;\n    }\n\n    @Override\n    public long getAgentStartTime() {\n        return startTime;\n    }\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/SqlUidMetaDataBo.java#L37-L73","documentation":"SqlUidMetaDataBo requires the sqlUid byte array to be exactly UidMetaDataRowKey.UID_LENGTH (16 bytes), matching the fixed-width key layout used in HBase storage. A null or wrong-length sqlUid is rejected in the constructor with this IllegalArgumentException.","triggerScenarios":"Constructing SqlUidMetaDataBo with a sqlUid array shorter or longer than 16 bytes, e.g. from parsing a malformed row key, a truncated hash, or passing a hex string's bytes without decoding to the full 16-byte digest.","commonSituations":"Using a 64-char hex SHA string's first/last bytes instead of the full 16-byte uid; row keys corrupted or re-encoded (e.g. Base64 vs raw) before BO construction; schema changes between Pinpoint versions altering key length.","solutions":["Ensure the sqlUid is the full 16-byte uid (e.g. a 128-bit hash) before constructing the BO","Decode hex/encoded keys back to raw bytes and verify length == 16 prior to construction","Regenerate or re-derive the uid from the SQL if the stored key was truncated"],"exampleFix":"// before\nbyte[] uid = sqlUidHex.getBytes(); // wrong: text length, not 16 bytes\nnew SqlUidMetaDataBo(serviceUid, agentId, startTime, appName, uid, sql);\n// after\nbyte[] uid = DatatypeConverter.parseHexBinary(sqlUidHex);\nif (uid.length != UidMetaDataRowKey.UID_LENGTH) {\n    throw new IllegalStateException(\"bad uid length \" + uid.length);\n}\nnew SqlUidMetaDataBo(serviceUid, agentId, startTime, appName, uid, sql);","handlingStrategy":"validation","validationCode":"if (sqlUid == null || sqlUid.length != UidMetaDataRowKey.UID_LENGTH) {\n    throw new IllegalArgumentException(\"sqlUid must be exactly \" + UidMetaDataRowKey.UID_LENGTH + \" bytes\");\n}\nnew SqlUidMetaDataBo(serviceUid, agentId, startTime, applicationName, sqlUid, sql);","typeGuard":"boolean isValidSqlUid(byte[] uid) {\n    return uid != null && uid.length == UidMetaDataRowKey.UID_LENGTH;\n}","tryCatchPattern":"try {\n    return new SqlUidMetaDataBo(serviceUid, agentId, startTime, appName, sqlUid, sql);\n} catch (IllegalArgumentException e) {\n    logger.warn(\"Rejecting metadata with bad sqlUid length\", e);\n    return null;\n}","preventionTips":["Keep uids as raw 16-byte hashes, never text-encoded byte arrays","Decode hex/Base64 keys to raw bytes and check length before constructing BOs","Use the shared UidMetaDataRowKey utilities to build and parse keys"],"tags":["java","validation","identifier"],"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-14T05:17:10.506Z"}