validate: treat legacy wide-format SETUP.csv as valid in single-file validate endpoint\n\nNow consistent with batch validation and import paths.
This commit is contained in:
@@ -1743,6 +1743,8 @@ async def validate_csv_file(
|
|||||||
mapping_info = _build_dynamic_mapping(csv_headers, model_class, file_type)
|
mapping_info = _build_dynamic_mapping(csv_headers, model_class, file_type)
|
||||||
mapped_headers = mapping_info["mapped_headers"]
|
mapped_headers = mapping_info["mapped_headers"]
|
||||||
unmapped_headers = mapping_info["unmapped_headers"]
|
unmapped_headers = mapping_info["unmapped_headers"]
|
||||||
|
# Accept legacy wide-format SETUP.csv as valid (Appl_Title, L_Head1..10, Default_Printer)
|
||||||
|
wide_ok = (file_type == "SETUP.csv" and _is_setup_wide_format(csv_headers))
|
||||||
|
|
||||||
# Sample data validation
|
# Sample data validation
|
||||||
sample_rows = []
|
sample_rows = []
|
||||||
@@ -1770,7 +1772,7 @@ async def validate_csv_file(
|
|||||||
return {
|
return {
|
||||||
"file_type": file_type,
|
"file_type": file_type,
|
||||||
# Consider valid if we can map at least one column; we don't require exact header match
|
# Consider valid if we can map at least one column; we don't require exact header match
|
||||||
"valid": len(mapped_headers) > 0 and len(errors) == 0,
|
"valid": (len(mapped_headers) > 0 or wide_ok) and len(errors) == 0,
|
||||||
"headers": {
|
"headers": {
|
||||||
"found": csv_headers,
|
"found": csv_headers,
|
||||||
"mapped": mapped_headers,
|
"mapped": mapped_headers,
|
||||||
@@ -1781,6 +1783,7 @@ async def validate_csv_file(
|
|||||||
"total_errors": len(errors),
|
"total_errors": len(errors),
|
||||||
"auto_mapping": {
|
"auto_mapping": {
|
||||||
"suggestions": mapping_info["suggestions"],
|
"suggestions": mapping_info["suggestions"],
|
||||||
|
"wide_format": wide_ok,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user