Skip to content

Commit 941371d

Browse files
author
bosd
committed
Update fix to handle JSON-RPC exceptions that contain IndexErrors
1 parent 8613b04 commit 941371d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/odoo_data_flow/import_threaded.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,29 @@ def _create_batch_individually(
416416
error_summary = "Malformed CSV row detected"
417417
continue
418418
except Exception as create_error:
419+
# Handle JSON-RPC exceptions that contain IndexErrors
420+
error_str = str(create_error).lower()
421+
422+
# Check if this is a JSON-RPC exception containing an IndexError/tuple index error
423+
if "tuple index out of range" in error_str or "indexerror" in error_str:
424+
error_message = f"Tuple unpacking error in row {i + 1}: {create_error}"
425+
failed_line = [*list(line), error_message]
426+
failed_lines.append(failed_line)
427+
if "Fell back to create" in error_summary:
428+
error_summary = "Tuple unpacking error detected"
429+
continue
430+
431+
# Handle other specific error types
419432
error_message = str(create_error).replace("\n", " | ")
433+
434+
# Handle "tuple index out of range" errors specifically
435+
if "tuple index out of range" in error_message:
436+
error_message = f"Tuple unpacking error in row {i + 1}: {error_message}"
437+
438+
# Handle invalid field errors (the new issue we discovered)
439+
elif "Invalid field" in error_message and "/id" in error_message:
440+
error_message = f"Invalid external ID field detected in row {i + 1}: {error_message}"
441+
420442
failed_line = [*list(line), error_message]
421443
failed_lines.append(failed_line)
422444
if "Fell back to create" in error_summary:

0 commit comments

Comments
 (0)