Skip to content

fix: use (name, subtype) tuple as deduplication key in add_deprecated_components#522

Closed
Rama542 wants to merge 1 commit into
open-telemetry:mainfrom
Rama542:fix/inventory-deprecation-subtype-dedup
Closed

fix: use (name, subtype) tuple as deduplication key in add_deprecated_components#522
Rama542 wants to merge 1 commit into
open-telemetry:mainfrom
Rama542:fix/inventory-deprecation-subtype-dedup

Conversation

@Rama542
Copy link
Copy Markdown
Contributor

@Rama542 Rama542 commented May 20, 2026

Closes #523

What this fixes

The add_deprecated_components method in InventoryManager was checking for duplicates using only the component name. That works fine when every component name is unique, but it breaks down as soon as two components share the same name under different subtypes.

Here is a concrete example. The Collector has extensions under both extension/encoding and extension/storage. If a component called zipkin existed under both, and the encoding variant was removed first and recorded as deprecated, then when the storage variant was removed later, the code would find zipkin already in existing_names and skip the second entry entirely. The storage deprecation would be permanently lost from the registry with no warning.

The fix

Changed the deduplication set from a flat set of names to a set of (name, subtype) tuples. This is exactly the same approach used to fix DeprecationDetector._build_component_set in PR 498 and issue 493. The detection side was already corrected there, and this PR corrects the persistence side so correctly detected removals are not dropped before they reach the registry.

Before:

existing_names = {comp["name"] for comp in deprecations[distribution][component_type]}

if component["name"] not in existing_names:

After:

existing_keys = {
    (comp["name"], comp.get("subtype"))
    for comp in deprecations[distribution][component_type]
}

if (component["name"], component.get("subtype")) not in existing_keys:

Tests

Added two new test cases in test_inventory.py:

test_add_deprecated_components_same_name_different_subtype
Verifies that when zipkin (encoding) is already in the index and zipkin (storage) is newly deprecated, both entries end up in the index.

test_add_deprecated_components_no_duplicate_same_name_and_subtype
Verifies that an entry with the exact same name and the exact same subtype is still correctly skipped, so the existing deduplication behavior is preserved.

All 145 tests in the collector-watcher suite pass.

…_components

The add_deprecated_components method was checking for duplicates using
component name alone. This caused it to silently skip a deprecation entry
when a component with the same name already existed in the index under a
different subtype.

For example, if zipkin encoding was already recorded as deprecated and
zipkin storage was later removed, the storage entry would be dropped
because zipkin was already seen in existing_names.

Changed the deduplication set to track (name, subtype) tuples so each
combination is treated as a distinct entry. Added two new test cases:
one that confirms both subtype entries are written when they differ,
and one that confirms a true duplicate (same name and same subtype) is
still skipped correctly.

This is a companion fix to the same bug addressed in DeprecationDetector
where _build_component_set was also keying on name alone.

Closes open-telemetry#519
@Rama542 Rama542 requested review from a team as code owners May 20, 2026 12:22
@netlify
Copy link
Copy Markdown

netlify Bot commented May 20, 2026

Deploy Preview for otel-ecosystem-explorer canceled.

Name Link
🔨 Latest commit 8d40d5b
🔍 Latest deploy log https://app.netlify.com/projects/otel-ecosystem-explorer/deploys/6a0da790a1eccc00083b4ade

@jaydeluca
Copy link
Copy Markdown
Member

is this a duplicate of #498 ?

@jaydeluca jaydeluca closed this May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: add_deprecated_components silently drops deprecations when two components share a name but have different subtypes

2 participants