Skip to content

Commit e6352d5

Browse files
fix: strip server-assigned ids before re-uploading annotations
`job.annotations()` returns existing annotations with their server-assigned `id` fields. When those are re-submitted via `set_annotations` (a full-replace PUT), CVAT rejects/mishandles them because it treats `id` as the identity of an existing object. Strip `id` from tags, shapes, and tracks in `JobAnnotations.request()` so the server creates them fresh. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 62cc3f7 commit e6352d5

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

next_cvat/client/job_annotations.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,22 @@ def add_tag_(
8484
return self
8585

8686
def request(self) -> models.LabeledDataRequest:
87+
def remove_id_from_dict(item_dict):
88+
"""Remove 'id' field from dictionary if present"""
89+
if isinstance(item_dict, dict):
90+
return {k: v for k, v in item_dict.items() if k != "id"}
91+
return item_dict
92+
8793
request = models.LabeledDataRequest()
8894
request.version = self.annotations["version"]
89-
request.tags = self.annotations["tags"]
90-
request.shapes = self.annotations["shapes"]
91-
request.tracks = self.annotations["tracks"]
95+
96+
# Remove ID fields from existing annotations
97+
request.tags = [remove_id_from_dict(tag) for tag in self.annotations["tags"]]
98+
request.shapes = [
99+
remove_id_from_dict(shape) for shape in self.annotations["shapes"]
100+
]
101+
request.tracks = [
102+
remove_id_from_dict(track) for track in self.annotations["tracks"]
103+
]
92104

93105
return request

0 commit comments

Comments
 (0)