roboflow/supervision · error · ValueError
Conflicting metadata for key: '{key}'.
Error message
Conflicting metadata for key: '{key}'. What it means
Raised by merge_metadata when the same metadata key holds different non-array (scalar/plain) values in two Detections being merged. After the ndarray special cases, plain inequality of the existing merged value and the new value is treated as a conflict, because merge_metadata has no policy for choosing between competing scalars.
Source
Thrown at src/supervision/detection/utils/internal.py:648
merged_metadata[key] = value
continue
other_value = merged_metadata[key]
if isinstance(value, np.ndarray) and isinstance(other_value, np.ndarray):
if not np.array_equal(merged_metadata[key], value):
raise ValueError(
f"Conflicting metadata for key: '{key}': "
f"{type(value)}, {type(other_value)}."
)
elif isinstance(value, np.ndarray) or isinstance(other_value, np.ndarray):
# Since [] == np.array([]).
raise ValueError(
f"Conflicting metadata for key: '{key}': "
f"{type(value)}, {type(other_value)}."
)
else:
if merged_metadata[key] != value:
raise ValueError(f"Conflicting metadata for key: '{key}'.")
return merged_metadata
def get_data_item(
data: _DetectionDataType,
index: int | slice | list[int] | npt.NDArray[np.integer | np.bool_],
) -> _DetectionDataType:
"""
Retrieve a subset of the data dictionary based on the given index.
Args:
data: The data dictionary of the Detections object.
index: The index or indices specifying the subset to retrieve.
Returns:
A subset of the data dictionary corresponding to the specified index.
"""View on GitHub (pinned to 7f254d9784)
Solutions
- Merge only Detections that share the metadata value (group inputs by metadata before merging), e.g. group by d.metadata['video_id'] and merge within each group
- Overwrite the conflicting key with a single intended value on all inputs before merge
- Drop the per-source key from metadata if it is not needed post-merge
Example fix
# before
merged = sv.Detections.merge([d_v1, d_v2]) # video_id 1 vs 2
# after
from itertools import groupby
groups = {}
for d in detections_list:
groups.setdefault(d.metadata.get('video_id'), []).append(d)
merged = [sv.Detections.merge(g) for g in groups.values()] Defensive patterns
Strategy: validation
Validate before calling
def split_by_metadata(detections_list, key):
groups = {}
for d in detections_list:
groups.setdefault(d.metadata.get(key), []).append(d)
return list(groups.values())
# merge within each group only Prevention
- Merge only Detections sharing identical metadata (group by the discriminating key first)
- Overwrite the varying metadata key before merging when a single canonical value is acceptable
- Design pipelines so merged batches share source/video/frame context
When it happens
Trigger: sv.Detections.merge([d1, d2]) with d1.metadata={'video_id': 1} and d2.metadata={'video_id': 2}; also the internal pair merge in core.py:3462 and annotations merge (core.py:3366) when inputs come from different videos/cameras.
Common situations: Concatenating Detections accumulated from multiple videos or camera streams where each carries its own video_id/source_id; batching detections per frame with frame-index metadata and merging across frames; reusing a merge helper on heterogeneous batches.
Related errors
- All metadata dictionaries must have the same keys to merge.
- Conflicting metadata for key: '{key}': {type(value)}, {type(
- Both Detections should have exactly 1 detected object.
- Value must be a np.ndarray or a list
- Detections confidence must be given for NMM to be executed.
AI-assisted analysis of roboflow/supervision@7f254d9784 (2026-08-15).
Data as JSON: /api/errors/c1e0f1651ce40e93.
Report an issue: GitHub.