{"record":{"id":"8cce974997ba6557","repo":"Crosstalk-Solutions/project-nomad","slug":"unexpected-fda-manifest-format-all-partitions-wer","errorCode":null,"errorMessage":"Unexpected FDA manifest format: all partitions were invalid (missing \"file\" field)","messagePattern":"Unexpected FDA manifest format: all partitions were invalid \\(missing \"file\" field\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"admin/util/drug_labels.ts","lineNumber":300,"sourceCode":"      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({\n      display_name: typeof part['display_name'] === 'string' ? part['display_name'] : '',\n      file: (part['file'] as string).trim(),\n      size_mb: typeof part['size_mb'] === 'string' ? part['size_mb'] : '0',\n      records: typeof part['records'] === 'number' ? part['records'] : 0,\n    })\n  }\n\n  if (partitions.length === 0) {\n    throw new Error(\n      'Unexpected FDA manifest format: all partitions were invalid (missing \"file\" field)'\n    )\n  }\n\n  return {\n    export_date: export_date.trim(),\n    total_records,\n    partitions,\n  }\n}\n\n// ─── Two-step ingest helpers (pure — no I/O) ──────────────────────────────────\n\n/**\n * Resolve the on-disk path of a part's zip from its manifest partition.\n *\n * The download job stages each part to `<storageBase>/<basename-of-file-URL>`;\n * both the download job (write) and the ingest job (read) must agree on this","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/Crosstalk-Solutions/project-nomad/blob/0bd1c6f4f9888d577fe232de06ac144bb8337131/admin/util/drug_labels.ts#L282-L318","documentation":"After filtering partition entries, parseDrugLabelManifest throws when zero entries had a valid 'file' field. Each partition is only kept if its 'file' property exists; if the upstream renamed the field or entries use a different shape, the accumulated partitions array stays empty and this guard fires.","triggerScenarios":"Every element of results.drug.label.partitions lacks a 'file' key — e.g. FDA renamed it to 'filename' or 'url', entries are strings instead of objects, or the array contains nulls/empty objects only.","commonSituations":"Upstream schema refactor of the partition entry shape; partially published manifest with placeholder entries; test fixtures modeled on outdated API docs; a transform layer mangling object keys (casing changes like File vs file).","solutions":["Log one raw partition entry (JSON.stringify(rawPartitions[0])) to see the actual key names and adjust the part['file'] extraction.","If keys are stable but casing/nesting changed, normalize entries before validation.","Update fixtures to mirror the current FDA manifest and add a unit test covering the rename so drift is caught in CI.","Fail fast with the observed entry shape in the error message to speed diagnosis."],"exampleFix":"// before\nif (partitions.length === 0) {\n  throw new Error('Unexpected FDA manifest format: all partitions were invalid (missing \"file\" field)')\n}\n// after\nif (partitions.length === 0) {\n  const sample = JSON.stringify(rawPartitions[0])\n  throw new Error(`Unexpected FDA manifest format: all partitions were invalid (missing \"file\" field). First entry: ${sample}`)\n}","handlingStrategy":"validation","validationCode":"const parts = label['partitions'] as unknown[]\nif (!parts.some((p) => p && typeof p === 'object' && 'file' in p)) {\n  // log first entry and abort before calling the parser\n}","typeGuard":"function isValidPartition(p: unknown): p is { file: string } {\n  return typeof p === 'object' && p !== null && typeof (p as any).file === 'string' && (p as any).file !== ''\n}","tryCatchPattern":"catch (e) { if (e.message.includes('all partitions were invalid')) logSampleEntry(rawPartitions[0]); throw e }","preventionTips":["Include a real partition entry in test fixtures","Include the offending entry shape in the error message for fast diagnosis","Add a CI test that parses a freshly-fetched manifest weekly to detect schema drift"],"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"}