{"record":{"id":"8e71434673a6ea55","repo":"SeaQL/sea-orm","slug":"failed-to-get-timestamp-8e7143","errorCode":null,"errorMessage":"Failed to get timestamp","messagePattern":"Failed to get timestamp","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_sqlite.rs","lineNumber":448,"sourceCode":"                        \"TEXT\" => Value::String(\n                            row.try_get::<Option<String>, _>(c.ordinal())\n                                .expect(\"Failed to get string\")\n                                .map(Box::new),\n                        ),\n\n                        \"BLOB\" => Value::Bytes(\n                            row.try_get::<Option<Vec<u8>>, _>(c.ordinal())\n                                .expect(\"Failed to get bytes\")\n                                .map(Box::new),\n                        ),\n\n                        #[cfg(feature = \"with-chrono\")]\n                        \"DATETIME\" => {\n                            use chrono::{DateTime, Utc};\n\n                            Value::ChronoDateTimeUtc(\n                                row.try_get::<Option<DateTime<Utc>>, _>(c.ordinal())\n                                    .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\")","sourceCodeStart":430,"sourceCodeEnd":466,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_sqlite.rs#L430-L466","documentation":"Panic when sea-orm-sync's SQLite driver (with-chrono feature) cannot decode a \"DATETIME\" column into Option<chrono::DateTime<Utc>> while building a ProxyRow. sqlx requires specific string formats (RFC3339 with offset) for DateTime<Utc>, so any DATETIME value stored in a different format — or NULL handled incorrectly — triggers this panic.","triggerScenarios":"Reading a SQLite DATETIME column whose stored text is not parseable as DateTime<Utc> (e.g. '2024-01-02 03:04:05' without offset or 'T' separator, unix epoch integers, naive local time) under the with-chrono feature.","commonSituations":"Timestamps written by other tools/libraries in SQLite's default 'YYYY-MM-DD HH:MM:SS' format; epoch seconds stored as INTEGER in a DATETIME column; values written by Python/Ruby ORMs with different formats; switching between with-chrono and with-time features.","solutions":["Normalize stored timestamps to RFC3339 with UTC offset (e.g. strftime('%Y-%m-%dT%H:%M:%SZ', col)) or re-write via datetime(col)","Write timestamps through chrono-typed entity fields so sqlx serializes the expected format","Check for NULL/epoch-integer values in the column and fix them before querying via ProxyRow","Propagate the sqlx error with column context instead of .expect and fall back to string values"],"exampleFix":"// before\nValue::ChronoDateTimeUtc(\n    row.try_get::<Option<DateTime<Utc>>, _>(c.ordinal())\n        .expect(\"Failed to get timestamp\")\n        .map(Box::new),\n)\n// after\nValue::ChronoDateTimeUtc(\n    row.try_get::<Option<DateTime<Utc>>, _>(c.ordinal())\n        .unwrap_or_else(|e| panic!(\"Failed to get timestamp for col {} ({}): {}\", c.name(), c.type_info().name(), e))\n        .map(Box::new),\n)   // root fix: ensure stored text is RFC3339, e.g. UPDATE t SET col = strftime('%Y-%m-%dT%H:%M:%SZ', col)","handlingStrategy":"validation","validationCode":"// Verify DATETIME columns store RFC3339-parseable UTC timestamps:\n// SELECT col FROM t WHERE datetime(col) IS NULL AND col IS NOT NULL;\nfn parses_as_utc(s: &str) -> bool { chrono::DateTime::parse_from_rfc3339(s).is_ok() }","typeGuard":"fn is_rfc3339(s: &str) -> bool { chrono::DateTime::parse_from_rfc3339(s).is_ok() }","tryCatchPattern":"let row = std::panic::catch_unwind(|| proxy_query(db)).unwrap_or_else(|_| fallback_row());","preventionTips":["Write timestamps via chrono-typed entity fields so sqlx uses RFC3339","Normalize foreign-written timestamps with strftime to ISO format","Keep with-chrono vs with-time consistent across write/read paths","Reject non-RFC3339 values at ingest time"],"tags":["rust","sqlx","sqlite","chrono","datetime","type-conversion","panic"],"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"}