Crosstalk-Solutions/project-nomad · error · Error

Unexpected FDA manifest format: "partitions" is missing or…

Error message

Unexpected FDA manifest format: "partitions" is missing or empty

What it means

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.

Solutions

  1. Fetch the manifest URL manually and verify results.drug.label.partitions is a populated array.
  2. If FDA moved/renamed the field, update the key extraction in parseDrugLabelManifest.
  3. Bust any HTTP cache between the app and the FDA endpoint (Cache-Control, proxy) and retry.
  4. If empty partitions can be legitimate (empty export), handle it explicitly with a no-op result instead of throwing.

Example fix

// before
const rawPartitions = label['partitions']
if (!Array.isArray(rawPartitions) || rawPartitions.length === 0) {
  throw new Error('Unexpected FDA manifest format: "partitions" is missing or empty')
}
// after
const rawPartitions = label['partitions']
if (!Array.isArray(rawPartitions)) {
  throw new Error(`Unexpected FDA manifest format: "partitions" was ${Array.isArray(rawPartitions) ? 'empty' : typeof rawPartitions}`)
}
if (rawPartitions.length === 0) {
  return { export_date: export_date.trim(), total_records, partitions: [] } // explicit empty export
}
Defensive patterns

Strategy: validation

Validate before calling

const parts = label?.['partitions']
if (!Array.isArray(parts) || parts.length === 0) {
  // treat as 'export not ready': retry later instead of parsing
}

Type guard

function hasPartitions(v: unknown): v is unknown[] {
  return Array.isArray(v) && v.length > 0
}

Try / catch

catch (e) { if (e.message.includes('partitions')) scheduleRetryOrAbort(); throw e }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Crosstalk-Solutions/project-nomad@0bd1c6f4f9 (2026-08-27). Data as JSON: /api/errors/c3427505510833ef. Report an issue: GitHub.

Appendix: source

Thrown at admin/util/drug_labels.ts:273

  const label = drug['label'] as Record<string, unknown> | undefined
  if (!label || typeof label !== 'object') {
    throw new Error('Unexpected FDA manifest format: missing "results.drug.label"')
  }

  const export_date = label['export_date']
  if (typeof export_date !== 'string' || export_date.trim() === '') {
    throw new Error('Unexpected FDA manifest format: missing or invalid "export_date"')
  }

  const total_records = label['total_records']
  if (typeof total_records !== 'number') {
    throw new Error('Unexpected FDA manifest format: missing or invalid "total_records"')
  }

  const rawPartitions = label['partitions']
  if (!Array.isArray(rawPartitions) || rawPartitions.length === 0) {
    throw new Error(
      'Unexpected FDA manifest format: "partitions" is missing or empty'
    )
  }

  const partitions: DrugLabelPartition[] = []
  for (const p of rawPartitions as unknown[]) {
    if (typeof p !== 'object' || p === null) {
      process.stderr.write('[parseDrugLabelManifest] Skipping non-object partition\n')
      continue
    }
    const part = p as Record<string, unknown>
    if (typeof part['file'] !== 'string' || (part['file'] as string).trim() === '') {
      process.stderr.write(
        `[parseDrugLabelManifest] Skipping partition with missing "file": ${JSON.stringify(part)}\n`
      )
      continue
    }
    partitions.push({

View on GitHub (pinned to 0bd1c6f4f9)