Skip to content

Conversation

@sjhddh
Copy link
Contributor

@sjhddh sjhddh commented Jan 23, 2026

Summary

Include the list index in multimodal validation error messages to help users identify which specific item has the issue.

Before:

Multi-modal data for image is None but UUID is not provided

After:

Multi-modal data for image[2] is None but UUID is not provided

Motivation

  • Improves debuggability when working with batched multimodal inputs
  • Makes it easier to identify which item in a list of images/videos/etc. is problematic

Test Plan

  • Test with a list of multimodal inputs where one item is None without UUID
  • Verify error message includes the correct index

Risk

  • Very low risk: only changes error message string format
  • No change to validation logic

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves error messages for multimodal validation by including the list index of the problematic item. This is a helpful change for debuggability. My review includes a suggestion to refactor the validation logic to improve its clarity, remove code duplication, and handle a potential edge case more robustly.

Comment on lines +1621 to 1622
f"Multi-modal data for {modality}[{i}] is None "
f"but UUID is not provided"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While adding the index to the error message is a good improvement, this logic for checking missing UUIDs is duplicated and can be simplified. The nested if/else and repeated raise ValueError makes the code harder to read and maintain.

Additionally, there's a potential issue: the code assumes multi_modal_uuids[modality] is a list because isinstance(data, list) is true. However, if multi_modal_uuids[modality] were a string, len() would work but indexing would behave differently, potentially leading to incorrect validation.

Consider refactoring the entire if d is None: block to be more concise and robust, like this:

if d is None:
    uuid_provided = False
    if multi_modal_uuids is not None:
        modality_uuids = multi_modal_uuids.get(modality)
        if isinstance(modality_uuids, list) and i < len(modality_uuids) and modality_uuids[i] is not None:
            uuid_provided = True

    if not uuid_provided:
        raise ValueError(
            f"Multi-modal data for {modality}[{i}] is None "
            f"but UUID is not provided")

This refactoring consolidates the validation logic, removes duplication, and adds a check to ensure modality_uuids is a list, making it safer.

When validating multimodal data lists, include the index in error
messages to help users identify which specific item has the issue.

Before: "Multi-modal data for image is None but UUID is not provided"
After:  "Multi-modal data for image[2] is None but UUID is not provided"

This improves debuggability when working with batched multimodal inputs.

Signed-off-by: 7. Sun <jhao.sun@gmail.com>
@sjhddh sjhddh force-pushed the fix/mm-validation-error-index branch from 3623be8 to 8fbf8a4 Compare January 23, 2026 23:24
Signed-off-by: 7. Sun <jhao.sun@gmail.com>
Copy link
Member

@DarkLight1337 DarkLight1337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, but I'm actually working on revamping the validation in #32955

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants