{"record":{"id":"2809430019eb6e78","repo":"koala73/worldmonitor","slug":"import-batch-requires-at-least-one-row","errorCode":null,"errorMessage":"import batch requires at least one row","messagePattern":"import batch requires at least one row","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"shared/company-monitoring-contract.ts","lineNumber":309,"sourceCode":"    throw new Error('ordinal must be between 0 and 99');\n  }\n\n  const normalized: NormalizedCompanyImportRow = {\n    contractVersion: COMPANY_MONITORING_IMPORT_VERSION,\n    clientImportId,\n    ordinal: input.ordinal,\n    ...normalizeMonitoredCompanyInput(input),\n  };\n\n  if (utf8Bytes(JSON.stringify(normalized)) > COMPANY_MONITORING_LIMITS.maxImportRowBytes) {\n    throw new Error(`row exceeds ${COMPANY_MONITORING_LIMITS.maxImportRowBytes} bytes`);\n  }\n  return normalized;\n}\n\nexport function normalizeCompanyImportBatch(inputs: CompanyImportRowInput[]): NormalizedCompanyImportRow[] {\n  if (!Array.isArray(inputs)) throw new Error('import batch must be a list');\n  if (inputs.length === 0) throw new Error('import batch requires at least one row');\n  if (inputs.length > COMPANY_MONITORING_LIMITS.maxImportRows) {\n    throw new Error(`batch exceeds ${COMPANY_MONITORING_LIMITS.maxImportRows} rows`);\n  }\n\n  const normalized = inputs.map(normalizeCompanyImportRow).sort((left, right) => left.ordinal - right.ordinal);\n  const importId = normalized[0]?.clientImportId;\n  for (let index = 0; index < normalized.length; index += 1) {\n    const row = normalized[index]!;\n    if (row.clientImportId !== importId) throw new Error('batch rows must share one clientImportId');\n    if (row.ordinal !== index) throw new Error('batch ordinals must be contiguous from 0');\n  }\n  if (utf8Bytes(JSON.stringify(normalized)) > COMPANY_MONITORING_LIMITS.maxImportBatchBytes) {\n    throw new Error(`batch exceeds ${COMPANY_MONITORING_LIMITS.maxImportBatchBytes} bytes`);\n  }\n  return normalized;\n}\n\nexport function assertCompanyMonitoringPayloadSize(byteLength: number): void {","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/koala73/worldmonitor/blob/eeab0a219fce0f02a00603b532dbae9041b934ac/shared/company-monitoring-contract.ts#L291-L327","documentation":"Contract validation error from normalizeCompanyImportBatch: the rows array exists but is empty. At least one row is required so an import cannot silently no-op.","triggerScenarios":"Thrown at shared/company-monitoring-contract.ts:309 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Include at least one valid import row in the batch","Skip calling the import endpoint when there is nothing to import"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"eeab0a219fce0f02a00603b532dbae9041b934ac","analyzedAt":"2026-08-21T16:51:25.751Z","contentChangedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}