fix: raise ValueError when external_id is used for NDJSON annotation import#2059
Open
sowndappan5 wants to merge 2 commits into
Open
fix: raise ValueError when external_id is used for NDJSON annotation import#2059sowndappan5 wants to merge 2 commits into
sowndappan5 wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a client-side validation error when
external_idis used inside aLabeldata container during NDJSON serialization (used for annotation/prediction imports).Previously, if a developer created a
Labelusing onlyexternal_id, the NDJSON serializer tried to build aDataRowwith bothidandglobal_keyasNone, causing Pydantic to throw a genericValidationError: Must set either id or global_key.Because the Labelbox annotation import (MAL) API does not natively support referencing data rows using
externalId, we added a descriptive validation check that raises a helpfulValueErrorinstructing developers to useglobal_keyor resolve theirexternal_idto adata_row_idbefore uploading.Fixes #1941
Type of change
All Submissions
New Feature Submissions
Changes to Core Features
Note
Low Risk
Adds pre-serialization validation and clearer errors only; valid
uid/global_keyimport paths are unchanged.Overview
NDJSON serialization (used for MAL/prediction and similar imports) now fails fast when a
Label’s data row is referenced only viaexternal_id, instead of surfacing a vague PydanticDataRowvalidation error.In
NDJsonConverter.serialize, each label is checked beforeNDLabel.from_common: iflabel.datais present but has neitheruidnorglobal_key, aValueErroris raised telling callers to useglobal_keyor resolveexternal_idto a data row id.A unit test asserts that
MALPredictionImport.create_from_objectswithdata={"external_id": "..."}raises that message.Reviewed by Cursor Bugbot for commit 23067a2. Bugbot is set up for automated code reviews on this repo. Configure here.