{"record":{"id":"c3427505510833ef","repo":"Crosstalk-Solutions/project-nomad","slug":"unexpected-fda-manifest-format-partitions-is-mi","errorCode":null,"errorMessage":"Unexpected FDA manifest format: \"partitions\" is missing or empty","messagePattern":"Unexpected FDA manifest format: \"partitions\" is missing or empty","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"admin/util/drug_labels.ts","lineNumber":273,"sourceCode":"\n  const label = drug['label'] as Record<string, unknown> | undefined\n  if (!label || typeof label !== 'object') {\n    throw new Error('Unexpected FDA manifest format: missing \"results.drug.label\"')\n  }\n\n  const export_date = label['export_date']\n  if (typeof export_date !== 'string' || export_date.trim() === '') {\n    throw new Error('Unexpected FDA manifest format: missing or invalid \"export_date\"')\n  }\n\n  const total_records = label['total_records']\n  if (typeof total_records !== 'number') {\n    throw new Error('Unexpected FDA manifest format: missing or invalid \"total_records\"')\n  }\n\n  const rawPartitions = label['partitions']\n  if (!Array.isArray(rawPartitions) || rawPartitions.length === 0) {\n    throw new Error(\n      'Unexpected FDA manifest format: \"partitions\" is missing or empty'\n    )\n  }\n\n  const partitions: DrugLabelPartition[] = []\n  for (const p of rawPartitions as unknown[]) {\n    if (typeof p !== 'object' || p === null) {\n      process.stderr.write('[parseDrugLabelManifest] Skipping non-object partition\\n')\n      continue\n    }\n    const part = p as Record<string, unknown>\n    if (typeof part['file'] !== 'string' || (part['file'] as string).trim() === '') {\n      process.stderr.write(\n        `[parseDrugLabelManifest] Skipping partition with missing \"file\": ${JSON.stringify(part)}\\n`\n      )\n      continue\n    }\n    partitions.push({","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/Crosstalk-Solutions/project-nomad/blob/0bd1c6f4f9888d577fe232de06ac144bb8337131/admin/util/drug_labels.ts#L255-L291","documentation":"parseDrugLabelManifest requires results.drug.label.partitions to be a non-empty array. The partitions list is what the drug-label import pipeline iterates to download files, so an empty or missing list means there is nothing to import and parsing throws immediately.","triggerScenarios":"FDA publishes a manifest before populating partitions (in-progress export), partitions is null/undefined or an object instead of an array, or a truncated/cached response strips the array.","commonSituations":"Hitting the manifest mid-publication when the export is staged but partition metadata is not yet written; stale cache serving a partial body; upstream schema change moving partitions elsewhere (e.g. nested under a version key); fixture without a partitions array.","solutions":["Fetch the manifest URL manually and verify results.drug.label.partitions is a populated array.","If FDA moved/renamed the field, update the key extraction in parseDrugLabelManifest.","Bust any HTTP cache between the app and the FDA endpoint (Cache-Control, proxy) and retry.","If empty partitions can be legitimate (empty export), handle it explicitly with a no-op result instead of throwing."],"exampleFix":"// before\nconst rawPartitions = label['partitions']\nif (!Array.isArray(rawPartitions) || rawPartitions.length === 0) {\n  throw new Error('Unexpected FDA manifest format: \"partitions\" is missing or empty')\n}\n// after\nconst rawPartitions = label['partitions']\nif (!Array.isArray(rawPartitions)) {\n  throw new Error(`Unexpected FDA manifest format: \"partitions\" was ${Array.isArray(rawPartitions) ? 'empty' : typeof rawPartitions}`)\n}\nif (rawPartitions.length === 0) {\n  return { export_date: export_date.trim(), total_records, partitions: [] } // explicit empty export\n}","handlingStrategy":"validation","validationCode":"const parts = label?.['partitions']\nif (!Array.isArray(parts) || parts.length === 0) {\n  // treat as 'export not ready': retry later instead of parsing\n}","typeGuard":"function hasPartitions(v: unknown): v is unknown[] {\n  return Array.isArray(v) && v.length > 0\n}","tryCatchPattern":"catch (e) { if (e.message.includes('partitions')) scheduleRetryOrAbort(); throw e }","preventionTips":["Retry with backoff — FDA sometimes publishes the manifest before partitions","Cache last known-good manifest to fall back to","Validate shape before entering the import pipeline"],"tags":["fda","manifest","schema-validation","partitions"],"backgroundTag":"schema-validation-failed","analyzedSha":"0bd1c6f4f9888d577fe232de06ac144bb8337131","analyzedAt":"2026-08-27T05:34:15.424Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}