{"record":{"id":"9c294703543ba319","repo":"koala73/worldmonitor","slug":"ordinal-must-be-between-0-and-99","errorCode":null,"errorMessage":"ordinal must be between 0 and 99","messagePattern":"ordinal must be between 0 and 99","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"shared/company-monitoring-contract.ts","lineNumber":291,"sourceCode":"\n  const customerReference = normalizeOptionalText(\n    input.customerReference,\n    'customerReference',\n    COMPANY_MONITORING_LIMITS.maxCustomerReferenceBytes,\n  );\n  if (customerReference !== undefined) normalized.customerReference = customerReference;\n  return normalized;\n}\n\nexport function normalizeCompanyImportRow(input: CompanyImportRowInput): NormalizedCompanyImportRow {\n  if (!input || typeof input !== 'object') throw new Error('import row is required');\n  const clientImportId = assertPlainText(\n    input.clientImportId,\n    'clientImportId',\n    COMPANY_MONITORING_LIMITS.maxClientImportIdBytes,\n  );\n  if (!Number.isSafeInteger(input.ordinal) || input.ordinal < 0 || input.ordinal >= COMPANY_MONITORING_LIMITS.maxImportRows) {\n    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');","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/koala73/worldmonitor/blob/eeab0a219fce0f02a00603b532dbae9041b934ac/shared/company-monitoring-contract.ts#L273-L309","documentation":"Contract validation error from normalizeCompanyImportRow: input.ordinal is not a safe integer in [0, maxImportRows). The ordinal preserves row order within a batch and doubles as a bound on batch size (currently 100 rows, 0–99).","triggerScenarios":"Thrown at shared/company-monitoring-contract.ts:291 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Assign each row a unique integer ordinal starting at 0","Split larger imports into multiple batches of at most 100 rows"],"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-14T05:17:10.506Z"}