{"record":{"id":"cf78215151a1511b","repo":"t8y2/dbx","slug":"excel-stream-ended-before-providing-a-header","errorCode":null,"errorMessage":"Excel stream ended before providing a header","messagePattern":"Excel stream ended before providing a header","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbx-core/src/table_import.rs","lineNumber":6493,"sourceCode":"                sender,\n                cancelled_for_producer,\n            )\n        });\n        let columns = loop {\n            let message = match receive_xlsx_stream_message(\n                &mut receiver,\n                &request.import_id,\n                &is_cancelled,\n                &producer_cancelled,\n            )\n            .await\n            {\n                Ok(Some(message)) => message,\n                Ok(None) => {\n                    let error = producer\n                        .await\n                        .map_err(|error| error.to_string())?\n                        .err()\n                        .unwrap_or_else(|| \"Excel stream ended before providing a header\".to_string());\n                    return Err(emit_import_error(&mut progress_callback, request, 0, 0, started_at, error));\n                }\n                Err(()) => {\n                    drop(receiver);\n                    let _ = producer.await;\n                    progress_callback(import_progress_with_details(\n                        &request.import_id,\n                        TableImportStatus::Cancelled,\n                        TableImportPhase::Done,\n                        0,\n                        0,\n                        false,\n                        last_xlsx_read_bytes,\n                        total_bytes,\n                        started_at,\n                        None,\n                    ));","sourceCodeStart":6475,"sourceCodeEnd":6511,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/crates/dbx-core/src/table_import.rs#L6475-L6511","documentation":"Raised when an Excel (xlsx) import stream closes without delivering a header row. The producer completed with Ok(None) and no error, so the importer substitutes this message. It prevents building a table from a workbook that produced no column metadata.","triggerScenarios":"Importing an xlsx whose first worksheet is empty; a producer that reads zero rows from the sheet; workbook with only formatting and no cell data; selecting a sheet/region that has no header row.","commonSituations":"Spreadsheets saved with headers deleted; importing the wrong sheet (data lives on another worksheet); template files never filled in; files corrupted mid-transfer.","solutions":["Open the workbook and confirm the target sheet has a header row in its first row","Verify the sheet selection/index in the import request points at the sheet containing data","Re-export or repair the xlsx if it appears truncated or empty","Check for a producer error surfaced before this fallback message"],"exampleFix":"// before\nimport_excel(\"template.xlsx\", sheet=1) // empty sheet 1\n// after\nimport_excel(\"data.xlsx\", sheet=1) // sheet 1 has headers in row 1","handlingStrategy":"validation","validationCode":"fn ensure_excel_sheet_has_data(path: &Path, sheet: usize) -> Result<(), String> {\n    // use a reader (e.g. calamine) to inspect before import\n    let mut wb = calamine::open_workbook_auto(path).map_err(|e| e.to_string())?;\n    let range = wb.worksheet_range_at(sheet)\n        .ok_or(\"sheet not found\")?\n        .map_err(|e| e.to_string())?;\n    if range.height() == 0 { return Err(\"sheet has no rows\".into()); }\n    Ok(())\n}","typeGuard":"fn sheet_has_header(range: &calamine::Range<calamine::Data>) -> bool {\n    range.height() > 0 && range.rows().next().map_or(false, |r| !r.is_empty())\n}","tryCatchPattern":"match importer.import_excel(request) {\n    Err(msg) if msg.contains(\"Excel stream ended before providing a header\") => {\n        eprintln!(\"Target worksheet is empty or missing a header row\");\n    }\n    other => other?,\n}","preventionTips":["Confirm the correct worksheet index/name before import","Open the workbook and check the first row is a header","Re-export corrupted/truncated xlsx files","Reject empty workbooks early in the upload pipeline"],"tags":["excel","xlsx","import","streaming","empty-input"],"backgroundTag":"empty-header-row","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}