{"record":{"id":"f3bd9105ee07c4b6","repo":"SeaQL/sea-orm","slug":"failed-to-get-date-f3bd91","errorCode":null,"errorMessage":"Failed to get date","messagePattern":"Failed to get date","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"sea-orm-sync/src/driver/sqlx_sqlite.rs","lineNumber":466,"sourceCode":"                                    .expect(\"Failed to get timestamp\")\n                                    .map(Box::new),\n                            )\n                        }\n                        #[cfg(all(feature = \"with-time\", not(feature = \"with-chrono\")))]\n                        \"DATETIME\" => {\n                            use time::OffsetDateTime;\n                            Value::TimeDateTimeWithTimeZone(\n                                row.try_get::<Option<OffsetDateTime>, _>(c.ordinal())\n                                    .expect(\"Failed to get timestamp\")\n                                    .map(Box::new),\n                            )\n                        }\n                        #[cfg(feature = \"with-chrono\")]\n                        \"DATE\" => {\n                            use chrono::NaiveDate;\n                            Value::ChronoDate(\n                                row.try_get::<Option<NaiveDate>, _>(c.ordinal())\n                                    .expect(\"Failed to get date\")\n                                    .map(Box::new),\n                            )\n                        }\n                        #[cfg(all(feature = \"with-time\", not(feature = \"with-chrono\")))]\n                        \"DATE\" => {\n                            use time::Date;\n                            Value::TimeDate(\n                                row.try_get::<Option<Date>, _>(c.ordinal())\n                                    .expect(\"Failed to get date\")\n                                    .map(Box::new),\n                            )\n                        }\n\n                        #[cfg(feature = \"with-chrono\")]\n                        \"TIME\" => {\n                            use chrono::NaiveTime;\n                            Value::ChronoTime(\n                                row.try_get::<Option<NaiveTime>, _>(c.ordinal())","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_sqlite.rs#L448-L484","documentation":"This panic occurs in sea-orm-sync's SQLite driver when converting a raw query result row into SeaORM Value objects. The column's declared type is \"DATE\" (with the with-chrono feature), and the driver calls row.try_get::<Option<NaiveDate>, _>(ordinal).expect(\"Failed to get date\"), which panics when sqlx cannot decode the stored value into a chrono NaiveDate. This is a fail-fast invariant: the driver trusts that the SQLite column type string matches the actual runtime value encoding.","triggerScenarios":"Executing a Select/Find query through the sync SQLite driver where a column is declared (or reported by SQLite) as type DATE, but the underlying stored value cannot be decoded as NaiveDate — e.g. a TEXT/NULL-incompatible blob, a malformed date string like '2026-13-45', or a value stored with the wrong affinity by a tool outside SeaORM.","commonSituations":"Migrating an existing SQLite database created by another ORM or hand-written SQL where DATE columns hold non-ISO strings; schema drift after renaming/altering columns with sqlite3 CLI; mixing the with-chrono feature with data written by the with-time codepath; bulk-loading data with sqlite3 .import that writes malformed dates.","solutions":["Inspect the offending column's stored values (SELECT the raw value with sqlite3 CLI) and fix or reformat them into valid 'YYYY-MM-DD' strings that NaiveDate can parse.","Alter the column's declared type to TEXT (or INTEGER) in the SQLite schema so the driver stops taking the DATE decode path, or use SeaORM's schema sync to recreate the table with the correct type.","Recreate the table via SeaORM migrations/entities so the column type in SQLite matches the Rust model type, then repopulate the data.","If you don't need date semantics, disable the with-chrono/with-time features so the column is read as a plain Value instead."],"exampleFix":"// before: column declared DATE holds malformed data\n// sqlite> SELECT my_date FROM my_table;  => '31/02/2026'\n\n// after: repair the data to an ISO date SQLite/sqlx can decode\n// sqlite> UPDATE my_table SET my_date = '2026-02-28' WHERE id = 1;\n// then re-run the query","handlingStrategy":"validation","validationCode":"// Run before querying: confirm DATE columns hold ISO-8601 dates\nlet bad: Vec<String> = sqlx::query_scalar(\n    \"SELECT my_date FROM my_table WHERE my_date IS NOT NULL AND my_date NOT GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'\")\n    .fetch_all(&pool).await?;\nassert!(bad.is_empty(), \"malformed DATE values: {:?}\", bad);","typeGuard":"fn is_valid_iso_date(s: &str) -> bool {\n    chrono::NaiveDate::parse_from_str(s, \"%Y-%m-%d\").is_ok()\n}","tryCatchPattern":"// Panics cannot be caught idiomatically; validate data instead.\n// If you must isolate it, run the query on a worker thread and inspect the JoinError:\nlet res = std::thread::spawn(move || sync_query()).join();\nmatch res {\n    Ok(v) => v,\n    Err(_) => return Err(Error::DbErrCustom(\"DATE column decode panic - check stored date format\".into())),\n}","preventionTips":["Validate imported/legacy data against ISO-8601 formats before pointing SeaORM at it","Keep declared SQLite column types aligned with entity field types via migrations","Decide on one date feature (with-chrono or with-time) and use it consistently across writes and reads","Never hand-edit schema types with the sqlite3 CLI on tables managed by SeaORM"],"tags":["sqlite","panic","date-parsing","type-decoding","database"],"backgroundTag":"invalid-date-format","analyzedSha":"e29bcd1b417c41a553b386fe94511d7c64a1c8ec","analyzedAt":"2026-09-10T11:31:52.468Z","contentChangedAt":"2026-09-10T11:31:52.468Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}