From 8488c2b1df37fe5b4712159884b2eb353d4a2850 Mon Sep 17 00:00:00 2001 From: Roland Tannous Date: Tue, 10 Mar 2026 01:42:25 +0000 Subject: [PATCH] fix: fall back to auto-detection when user VLM mapping fails Instead of erroring out when custom_format_mapping fails conversion, clear it and let auto-detection try. Handles stale cached mappings. --- .../backend/utils/datasets/dataset_utils.py | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/studio/backend/utils/datasets/dataset_utils.py b/studio/backend/utils/datasets/dataset_utils.py index eb6ab864a2..2b430cee14 100644 --- a/studio/backend/utils/datasets/dataset_utils.py +++ b/studio/backend/utils/datasets/dataset_utils.py @@ -689,17 +689,15 @@ def format_and_template_dataset( "errors": [], } except Exception as e: - errors.append(f"Failed to apply user VLM mapping: {e}") - return { - "dataset": dataset, - "detected_format": "user_mapped", - "final_format": "vlm_conversion_failed", - "is_vlm": True, - "success": False, - "requires_manual_mapping": True, - "warnings": warnings, - "errors": errors, - } + # User mapping failed — fall back to auto-detection instead + # of giving up (handles stale cached mappings gracefully) + warnings.append( + f"User VLM mapping (image='{user_vlm_image_column}', " + f"text='{user_vlm_text_column}') failed: {e} — " + f"falling back to auto-detection" + ) + print(f"⚠️ User VLM mapping failed, falling back to auto-detection...") + custom_format_mapping = None # clear so auto-detection runs below else: errors.append( f"Invalid VLM mapping: need 'image' and 'text' roles. Got: {custom_format_mapping}"