Crosstalk-Solutions/project-nomad · error · Error
Unexpected FDA manifest format: all partitions were invalid
Error message
Unexpected FDA manifest format: all partitions were invalid (missing "file" field)
What it means
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.
Source
Thrown at admin/util/drug_labels.ts:300
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({
display_name: typeof part['display_name'] === 'string' ? part['display_name'] : '',
file: (part['file'] as string).trim(),
size_mb: typeof part['size_mb'] === 'string' ? part['size_mb'] : '0',
records: typeof part['records'] === 'number' ? part['records'] : 0,
})
}
if (partitions.length === 0) {
throw new Error(
'Unexpected FDA manifest format: all partitions were invalid (missing "file" field)'
)
}
return {
export_date: export_date.trim(),
total_records,
partitions,
}
}
// ─── Two-step ingest helpers (pure — no I/O) ──────────────────────────────────
/**
* Resolve the on-disk path of a part's zip from its manifest partition.
*
* The download job stages each part to `<storageBase>/<basename-of-file-URL>`;
* both the download job (write) and the ingest job (read) must agree on thisView on GitHub (pinned to 0bd1c6f4f9)
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.
Example fix
// before
if (partitions.length === 0) {
throw new Error('Unexpected FDA manifest format: all partitions were invalid (missing "file" field)')
}
// after
if (partitions.length === 0) {
const sample = JSON.stringify(rawPartitions[0])
throw new Error(`Unexpected FDA manifest format: all partitions were invalid (missing "file" field). First entry: ${sample}`)
} Defensive patterns
Strategy: validation
Validate before calling
const parts = label['partitions'] as unknown[]
if (!parts.some((p) => p && typeof p === 'object' && 'file' in p)) {
// log first entry and abort before calling the parser
} Type guard
function isValidPartition(p: unknown): p is { file: string } {
return typeof p === 'object' && p !== null && typeof (p as any).file === 'string' && (p as any).file !== ''
} Try / catch
catch (e) { if (e.message.includes('all partitions were invalid')) logSampleEntry(rawPartitions[0]); throw e } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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).
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
- Unexpected FDA manifest format: "partitions" is missing or e
- Unexpected FDA manifest format: missing or invalid "export_d
- Unexpected FDA manifest format: missing or invalid "total_re
- HTTP ${resp.status} from ${MANIFEST_URL}
AI-assisted analysis of Crosstalk-Solutions/project-nomad@0bd1c6f4f9 (2026-08-27).
Data as JSON: /api/errors/8cce974997ba6557.
Report an issue: GitHub.