{"record":{"id":"8c26c1825aed1bd6","repo":"alibaba/canal","slug":"rowkey","errorCode":null,"errorMessage":"RowKey 值为空","messagePattern":"RowKey 值为空","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"client-adapter/hbase/src/main/java/com/alibaba/otter/canal/client/adapter/hbase/service/HbaseEtlService.java","lineNumber":242,"sourceCode":"                                row.addCell(columnItem.getFamily(),\n                                    columnItem.getQualifier(),\n                                    TypeUtil.toBytes(val, type));\n                            }\n                        } else if (MappingConfig.Mode.PHOENIX == hbaseMapping.getMode()) {\n                            PhType phType = PhType.getType(columnItem.getType());\n                            if (columnItem.isRowKey()) {\n                                row.setRowKey(PhTypeUtil.toBytes(val, phType));\n                            } else {\n                                row.addCell(columnItem.getFamily(),\n                                    columnItem.getQualifier(),\n                                    PhTypeUtil.toBytes(val, phType));\n                            }\n                        }\n                    }\n                }\n            }\n\n            if (row.getRowKey() == null) throw new RuntimeException(\"RowKey 值为空\");\n\n            rows.add(row);\n            complete = false;\n            if (i % hbaseMapping.getCommitBatch() == 0 && !rows.isEmpty()) {\n                hbaseTemplate.puts(hbaseMapping.getHbaseTable(), rows);\n                rows.clear();\n                complete = true;\n            }\n            i++;\n            impCount.incrementAndGet();\n            if (logger.isDebugEnabled()) {\n                logger.debug(\"successful import count:\" + impCount.get());\n            }\n        }\n\n        if (!complete && !rows.isEmpty()) {\n            hbaseTemplate.puts(hbaseMapping.getHbaseTable(), rows);\n        }","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/client-adapter/hbase/src/main/java/com/alibaba/otter/canal/client/adapter/hbase/service/HbaseEtlService.java#L224-L260","documentation":"HbaseEtlService import throws when a built HRow has a null rowKey after processing all mapped columns. HBase requires a non-null row key to write, so a row whose source data produced no rowKey value (composite-key columns all null AND no ROWKEY-marked column resolved) is rejected.","triggerScenarios":"Running a full ETL import where a source row has null values in every column used for the rowKey (whether composite 'rowKey:' columns or a single ROWKEY column), so row.setRowKey(...) was never called.","commonSituations":"Source table rows with NULL primary-key columns; a mapping whose rowKey references a column that does not exist in the source data; composite rowKey where all constituent columns are null.","solutions":["Ensure every source row has non-null values in the column(s) used as the rowKey.","Fix the mapping so rowKey references actual existing source columns.","Cleanse null-PK source rows upstream before ETL.","If using a single ROWKEY column, confirm exactly one column is marked ROWKEY and is populated."],"exampleFix":"-- before: source row has NULL id\n-- after: backfill/cleanse so id is non-null\nUPDATE t_user SET id = <generated> WHERE id IS NULL;","handlingStrategy":"validation","validationCode":"// Before ETL, ensure source rows have non-null rowKey columns\nList<String> rowKeyCols = hbaseMapping.getRowKey() != null\n    ? Arrays.asList(hbaseMapping.getRowKey().split(\",\"))\n    : Collections.singletonList(hbaseMapping.getRowKeyColumn().getColumn());\nfor (Map<String,Object> row : data) {\n    boolean anyNull = rowKeyCols.stream().anyMatch(c -> row.get(c.trim()) == null);\n    if (anyNull) throw new IllegalStateException(\"Source row missing rowKey value: \" + row);\n}","typeGuard":null,"tryCatchPattern":"try {\n    hbaseEtlService.importData(...);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"RowKey\")) {\n        logger.error(\"A source row produced no rowKey; cleanse null-PK rows upstream\");\n    }\n    throw e;\n}","preventionTips":["Guarantee non-null values in all rowKey columns of source data.","Verify the rowKey column names exist in the source schema.","Run a data-quality pass before ETL."],"tags":["hbase-adapter","etl","rowkey","data-quality"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}