Backport: Ignore namespace filtering for self-managed instances in historical add-on assignments

Summary

Create a backport solution to handle self-managed instances where historical add-on assignments have a default namespace of 0/ because add-on assignments are not specified to a namespace in self-managed environments.

Problem

In self-managed GitLab instances, add-on assignments are not namespace-specific, resulting in a default namespace path of 0/. The current implementation in ee/app/finders/gitlab_subscriptions/concerns/historical_add_on_assigned_users.rb filters by namespace path, which causes issues for self-managed instances to map AI Metrics correctly in the SDLC analytics dashboards and ai metrics grpahQL endpoints

In HistoricalAddOnAssignedUsers:

        raw_query = <<~SQL
          WITH latest_assignment_state AS (
            ...
            FROM user_add_on_assignments_history
            WHERE namespace_path = {root_namespace:String} # namespace_path here is either project or group. which doesn't match with the addon assignment namespace mapping in self-managed 
            ...
        SQL

Proposed Solution

Modify the historical_add_on_assigned_users finder to ignore/skip namespace filtering when:

  • The instance is self-managed (not GitLab.com)
  • OR the namespace path is 0/

This should be implemented in ee/app/finders/gitlab_subscriptions/concerns/historical_add_on_assigned_users.rb by adjusting the ClickHouse query to conditionally apply the namespace filter.

Implementation Details

Update the user_ids_with_active_assignments_in_period method to:

  1. Detect if the instance is self-managed using Gitlab.com? or similar check
  2. Skip the namespace_path filter in the ClickHouse query when on self-managed
  3. Ensure the query still filters by add_on_name and date ranges

Related

  • Parent issue: #590326
  • Related issue: #588733
  • Epic: &20540
Edited Feb 24, 2026 by Amr Taha
Assignee Loading
Time tracking Loading