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 <noreply@anthropic.com>
This commit is contained in:
@@ -43,6 +43,12 @@ def format_db_error(raw_error: str) -> StandardError:
|
|||||||
recoverable = True
|
recoverable = True
|
||||||
elif code in [1054, 1146]: # Unknown column / Table
|
elif code in [1054, 1146]: # Unknown column / Table
|
||||||
category = "database_schema"
|
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:
|
else:
|
||||||
category = "database"
|
category = "database"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user