koala73/worldmonitor · error · Error

import batch requires at least one row

Error message

import batch requires at least one row

What it means

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.

Solutions

  1. Include at least one valid import row in the batch
  2. Skip calling the import endpoint when there is nothing to import
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at shared/company-monitoring-contract.ts:309 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of koala73/worldmonitor@eeab0a219f (2026-08-21). Data as JSON: /api/errors/2809430019eb6e78. Report an issue: GitHub.

Appendix: source

Thrown at shared/company-monitoring-contract.ts:309

    throw new Error('ordinal must be between 0 and 99');
  }

  const normalized: NormalizedCompanyImportRow = {
    contractVersion: COMPANY_MONITORING_IMPORT_VERSION,
    clientImportId,
    ordinal: input.ordinal,
    ...normalizeMonitoredCompanyInput(input),
  };

  if (utf8Bytes(JSON.stringify(normalized)) > COMPANY_MONITORING_LIMITS.maxImportRowBytes) {
    throw new Error(`row exceeds ${COMPANY_MONITORING_LIMITS.maxImportRowBytes} bytes`);
  }
  return normalized;
}

export function normalizeCompanyImportBatch(inputs: CompanyImportRowInput[]): NormalizedCompanyImportRow[] {
  if (!Array.isArray(inputs)) throw new Error('import batch must be a list');
  if (inputs.length === 0) throw new Error('import batch requires at least one row');
  if (inputs.length > COMPANY_MONITORING_LIMITS.maxImportRows) {
    throw new Error(`batch exceeds ${COMPANY_MONITORING_LIMITS.maxImportRows} rows`);
  }

  const normalized = inputs.map(normalizeCompanyImportRow).sort((left, right) => left.ordinal - right.ordinal);
  const importId = normalized[0]?.clientImportId;
  for (let index = 0; index < normalized.length; index += 1) {
    const row = normalized[index]!;
    if (row.clientImportId !== importId) throw new Error('batch rows must share one clientImportId');
    if (row.ordinal !== index) throw new Error('batch ordinals must be contiguous from 0');
  }
  if (utf8Bytes(JSON.stringify(normalized)) > COMPANY_MONITORING_LIMITS.maxImportBatchBytes) {
    throw new Error(`batch exceeds ${COMPANY_MONITORING_LIMITS.maxImportBatchBytes} bytes`);
  }
  return normalized;
}

export function assertCompanyMonitoringPayloadSize(byteLength: number): void {

View on GitHub (pinned to eeab0a219f)