feat(csv-templates): Add CSV template validation endpoint and enhance error handling
Deploy Development / deploy (push) Successful in 55s
Build Test / pytest-backend (push) Successful in 4s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 17s

- 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:
Lars committed 2026-04-11 06:47:27 +02:00
1 parent 6945b748cb
commit 0629f88b37
10 files changed
+486 -39

No files matched your search

+11
View File
@@ -29,6 +29,15 @@ export function formatFastApiDetail(detail, fallback = '') {
return parts.length ? parts.join(' · ') : fallback || 'Validierungsfehler'
}
if (typeof detail === 'object') {
if (Array.isArray(detail.errors) && detail.errors.length > 0) {
const parts = detail.errors
.map((e) => {
if (e && typeof e === 'object') return e.message || e.msg || ''
return String(e)
})
.filter(Boolean)
if (parts.length) return parts.join(' · ')
}
if (typeof detail.msg === 'string') return detail.msg
if (typeof detail.message === 'string') return detail.message
}
@@ -554,6 +563,8 @@ export const api = {
return j
},
adminGetCsvTemplate: (id) => req(`/admin/csv-templates/${id}`),
/** Formatprüfung (ohne Speichern); body wie Create, import_row_processing optional */
adminValidateCsvTemplate: (d) => req('/admin/csv-templates/validate', json(d)),
adminCreateCsvTemplate: (d) => req('/admin/csv-templates', json(d)),
adminUpdateCsvTemplate: (id, d) => req(`/admin/csv-templates/${id}`, jput(d)),
adminDeleteCsvTemplate: (id) => req(`/admin/csv-templates/${id}`, { method: 'DELETE' }),