Skip to content

Implicit tag count merges same-named tags from different taxonomies #955

Open

Description

@mgwozdz-unicon

Description drafted by Claude:

get_object_tag_counts(..., count_implicit=True) in src/openedx_tagging/api.py undercounts when an object has tags from two taxonomies whose lineages are the same text.

The implicit count collects each tag's lineage prefixes into one set per object. A lineage is only the tag values joined by tabs, with no taxonomy in it, so "Shared" in taxonomy A and "Shared" in taxonomy B become one set entry.

To reproduce: create two taxonomies, add a root tag named Shared to each, and tag obj1 with both. get_object_tag_counts("obj1") returns 2, and get_object_tag_counts("obj1", count_implicit=True) returns 1. The implicit count should never be lower than the explicit one. Confirmed on main on 2026-11-20.

Likely fix: keep taxonomy_id in the selected rows and key the set by (taxonomy_id, prefix), plus a regression test for the case above.

Found by CodeRabbit during review of #940. The code predates that PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions