{"record":{"id":"ecb5fb00fba9ceeb","repo":"tursodatabase/turso","slug":"unexpected-serial-type-for-column-of-the-fixture-row","errorCode":null,"errorMessage":"unexpected serial type {} for column {} of the fixture row, expected {}","messagePattern":"unexpected serial type (.+?) for column (.+?) of the fixture row, expected (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"testing/sqltest/src/generator/mod.rs","lineNumber":1085,"sourceCode":"\n    let (header_size, header_size_varint_len) = parse_sqlite_varint(&bytes, payload_start)?;\n    let header_end = payload_start + header_size as usize;\n    anyhow::ensure!(\n        header_end <= bytes.len(),\n        \"record header out of bounds on page {root_page}\"\n    );\n\n    let mut serial_offset = payload_start + header_size_varint_len;\n    for _ in 0..patch.column_index {\n        let (_, serial_len) = parse_sqlite_varint(&bytes, serial_offset)?;\n        serial_offset += serial_len;\n    }\n    anyhow::ensure!(\n        serial_offset < header_end,\n        \"record has no column {} on page {root_page}\",\n        patch.column_index\n    );\n    anyhow::ensure!(\n        bytes[serial_offset] == patch.expected_serial_type,\n        \"unexpected serial type {} for column {} of the fixture row, expected {}\",\n        bytes[serial_offset],\n        patch.column_index,\n        patch.expected_serial_type\n    );\n    bytes[serial_offset] = patch.new_serial_type;\n\n    std::fs::write(db_path, bytes)\n        .with_context(|| format!(\"failed to write fixture '{}'\", db_path.display()))?;\n    Ok(())\n}\n\nasync fn generate_non_unique_index_entry_fixture(db_path: &Path) -> Result<()> {\n    clear_existing_db_and_sidecars(db_path)?;\n\n    let db_path_str = db_path.to_string_lossy().to_string();\n    let db = Builder::new_local(&db_path_str)","sourceCodeStart":1067,"sourceCodeEnd":1103,"githubUrl":"https://github.com/tursodatabase/turso/blob/8d4a589f8d13ac184700d2a8f724f27e1995be3b/testing/sqltest/src/generator/mod.rs#L1067-L1103","documentation":"The generator verifies that the serial-type byte at the target column's header offset equals `patch.expected_serial_type` before rewriting it. A mismatch means the stored value's type differs from what the patch assumed (e.g. the value isn't stored as INTEGER), so an in-place patch would produce an invalid record and the generator refuses.","triggerScenarios":"`patch_first_row_serial_type` finds `bytes[serial_offset] != patch.expected_serial_type` — e.g. the column was created without NOT NULL, stores NULL (type 0), or the schema affinity changed the stored type.","commonSituations":"Fixture schema changed so the first row's value serializes differently, patching a generated column that stores a different type, or reusing a patch built for another fixture variant.","solutions":["Update `patch.expected_serial_type` to match the actual stored serial type in the fixture row.","Adjust the fixture's INSERT so the first row stores the assumed type (e.g. a non-NULL integer).","Re-derive the expected serial type from the schema/affinity before patching."],"exampleFix":"// before\nlet patch = FirstRowSerialTypePatch { expected_serial_type: 1, .. }; // row stores NULL (0)\n// after\n// fixture: INSERT INTO t VALUES (1, ...) ensuring NOT NULL column stores integer\nlet patch = FirstRowSerialTypePatch { expected_serial_type: 1, new_serial_type: 0, .. };","handlingStrategy":"validation","validationCode":"let actual = read_serial_type_at(&db_path, root_page, patch.column_index)?;\nassert_eq!(actual, patch.expected_serial_type, \"fixture row column {} stores serial type {}\", patch.column_index, actual);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure fixture INSERTs store the assumed type (non-NULL integers for int columns)","Re-derive expected serial type from column affinity","Inspect the raw page with a hex dump when in doubt"],"tags":["sqlite","fixture","serial-type","testing"],"backgroundTag":"internal-invariant-violation","analyzedSha":"8d4a589f8d13ac184700d2a8f724f27e1995be3b","analyzedAt":"2026-09-20T13:18:14.658Z","contentChangedAt":"2026-09-20T13:18:14.658Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}