From 308a7f296f617608dffde1d74828d66d3c1e09b7 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Tue, 17 Mar 2026 18:39:50 -0400 Subject: [PATCH] fix(errors): classify 1364 as database_schema with actionable message Parses the field name from the MariaDB error and returns a clear "Schema mismatch: column 'X' is NOT NULL..." message instead of the raw DB string. Consistent with how 1054/1146 (unknown column/table) are already handled. Co-Authored-By: Claude Sonnet 4.6 --- app/lib_api_crud_v3.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/lib_api_crud_v3.py b/app/lib_api_crud_v3.py index e441b6c..c49b5ec 100644 --- a/app/lib_api_crud_v3.py +++ b/app/lib_api_crud_v3.py @@ -43,6 +43,12 @@ def format_db_error(raw_error: str) -> StandardError: recoverable = True elif code in [1054, 1146]: # Unknown column / Table category = "database_schema" + elif code == 1364: # Field has no default value — model/schema mismatch + category = "database_schema" + field_match = re.search(r"Field '([^']+)' doesn't have a default value", message) + if field_match: + field_name = field_match.group(1) + message = f"Schema mismatch: column '{field_name}' is NOT NULL with no default but was not included in the insert. Check the model definition and database schema." else: category = "database"