feat(csv-templates): Add CSV template validation endpoint and enhance error handling
- Introduced a new endpoint for validating CSV templates without saving, allowing users to check field mappings and type conversions. - Updated the `create_system_template` and `update_system_template` functions to include validation reports in responses. - Enhanced error handling in CSV import processes by integrating `enrich_row_error` for more informative error messages. - Improved the AdminCsvTemplateEditorPage to support format checking and display validation results, enhancing user experience. - Incremented version numbers for `csv_import` and `admin_csv_templates` to reflect these updates.
This commit is contained in:
1 parent
6945b748cb
commit
0629f88b37
10 files changed
+486
-39
No files matched your search
@@ -18,6 +18,7 @@ from csv_parser.import_row_processing import (
|
||||
validate_import_row_processing,
|
||||
)
|
||||
from csv_parser.module_registry import get_module_definition
|
||||
from csv_parser.import_errors import enrich_row_error
|
||||
from csv_parser.type_converter import build_row_after_mapping
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -756,8 +757,9 @@ def _import_vitals_baseline(
|
||||
cur.execute("ROLLBACK TO SAVEPOINT vitals_csv_row")
|
||||
except Exception:
|
||||
pass
|
||||
err = enrich_row_error(str(e), module="vitals_baseline")
|
||||
error_details.append(
|
||||
{"row": rows_total, "error": str(e), "context": "vitals_baseline upsert"},
|
||||
{"row": rows_total, "context": "vitals_baseline upsert", **err},
|
||||
)
|
||||
|
||||
return {
|
||||
@@ -1003,7 +1005,8 @@ def _import_activity(
|
||||
cur.execute("ROLLBACK TO SAVEPOINT csv_activity_row")
|
||||
except Exception:
|
||||
pass
|
||||
error_details.append({"row": rows_total, "error": str(e)})
|
||||
err = enrich_row_error(str(e), module="activity")
|
||||
error_details.append({"row": rows_total, **err})
|
||||
|
||||
return {
|
||||
"rows_total": rows_total,
|
||||
|
||||
Reference in new issue
Block a user