-
-
Notifications
You must be signed in to change notification settings - Fork 12.9k
[Fix] Include list index in multimodal validation error messages #32985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
| f"Multi-modal data for {modality}[{i}] is None " | ||
| f"but UUID is not provided" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
3623be8 to
8fbf8a4
Compare
Signed-off-by: 7. Sun <jhao.sun@gmail.com>
DarkLight1337
left a comment
There was a problem hiding this 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
Summary
Include the list index in multimodal validation error messages to help users identify which specific item has the issue.
Before:
After:
Motivation
Test Plan
Risk