koala73/worldmonitor · error · Error
import batch must be a list
Error message
import batch must be a list
What it means
Contract validation error from normalizeCompanyImportBatch: the import payload is not a JSON array. Null/undefined inputs return an empty batch; strings, objects, or other non-array types hit this guard.
Source
Thrown at shared/company-monitoring-contract.ts:308
if (!Number.isSafeInteger(input.ordinal) || input.ordinal < 0 || input.ordinal >= COMPANY_MONITORING_LIMITS.maxImportRows) {
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;
}
View on GitHub (pinned to eeab0a219f)
Solutions
- Send the batch as a JSON array of import row objects
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at shared/company-monitoring-contract.ts:308 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/767fc2525d3a5c89.
Report an issue: GitHub.