Skip to content

Fix SlackIntegration duplicate bug when inheriting from parent

What does this MR do and why?

This MR fixes an issue where SlackIntegration records are not properly created when inheriting GitLab Slack Application integrations from group or instance level to projects.

Problem

When calling Integration.build_from_integration to create project-level integrations from parent (group/instance) integrations:

  • The dup method doesn't duplicate associated records (slack_integration)
  • The new integration lacks the required SlackIntegration association
  • This causes the integration to fail as the alias field (required for Slack commands) is missing

Solution

Introduces a after_build_from_integration hook in the integration inheritance flow:

  1. Added after_build_from_integration method to Integration base class (no-op by default)
  2. build_from_integration calls this hook after setting the parent context
  3. GitlabSlackApplication overrides this hook to duplicate the slack_integration with the correct alias based on the new parent's full_path

This ensures that when projects inherit Slack integrations from their parent group/instance, they get properly configured SlackIntegration records with unique aliases.

References

Screenshots or screen recordings

Before After

How to test

Test instance-level inheritance

  1. Enable GitLab for Slack app feature:

    • Navigate to Admin Area > Settings > General
    • Expand GitLab for Slack app section
    • Check Enable GitLab for Slack app
    • Save changes
  2. Configure instance-level integration:

    • Navigate to Admin Area > Settings > Integrations
    • Click on GitLab for Slack app
    • Install/configure the integration
    • Save the integration
  3. Verify project inheritance:

    • Create a new project
    • Navigate to Project > Settings > Integrations
    • Verify GitLab for Slack app shows as inherited (with inheritance icon)
    • Click on the integration
    • Verify the button shows "Reinstall GitLab for Slack app" (not a broken state)

Test group-level inheritance

  1. Enable GitLab for Slack app feature (same as step 1 above)

  2. Configure group-level integration:

    • Navigate to Group > Settings > Integrations
    • Click on GitLab for Slack app
    • Install/configure the integration
    • Save the integration
  3. Verify project inheritance:

    • Create a new project under this group
    • Navigate to Project > Settings > Integrations
    • Verify GitLab for Slack app shows as inherited from group
    • Click on the integration
    • Verify the button shows "Reinstall GitLab for Slack app" (not a broken state)

Expected behavior

  • The integration should be properly inherited without errors
  • The SlackIntegration association should be created with correct alias
  • The "Reinstall" button should be functional

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #461056 (closed)

Edited by Rez

Merge request reports

Loading