Limit issue keys associated with Jira Deployments to 500 max

Problem

We currently associate Jira deployments with around 5,000 Jira issue keys.

A message from Atlassian in Slack (internal, good for 90 days) pointed out that the associations property is limited to 500 values for issue keys, and a payload send to the endpoint that contains more items that this is likely rejected as invalid.

Proposal

  • Limit the number of keys we send to 500 max.
  • Make a documentation change: (See the small notes next to Commit message in this table).

It may make sense to additionally limit the number of commits that we scan for Jira issue keys down to 2,000 due to the limit of 500 max keys.

A proposed patch is:

diff --git a/lib/atlassian/jira_connect/serializers/deployment_entity.rb b/lib/atlassian/jira_connect/serializers/deployment_entity.rb
index 1feb8a60f738..cd7306f4db19 100644
--- a/lib/atlassian/jira_connect/serializers/deployment_entity.rb
+++ b/lib/atlassian/jira_connect/serializers/deployment_entity.rb
@@ -6,7 +6,8 @@ module Serializers
       class DeploymentEntity < Grape::Entity
         include Gitlab::Routing

-        COMMITS_LIMIT = 5_000
+        COMMITS_LIMIT = 2_000
+        ISSUE_KEY_LIMIT = 500

         format_with(:iso8601, &:iso8601)

@@ -24,7 +25,9 @@ class DeploymentEntity < Grape::Entity
         expose :environment_entity, as: :environment

         def issue_keys
-          @issue_keys ||= (issue_keys_from_pipeline + issue_keys_from_commits_since_last_deploy).uniq
+          @issue_keys ||= (
+            issue_keys_from_pipeline + issue_keys_from_commits_since_last_deploy
+            ).uniq.first(ISSUE_KEY_LIMIT)
         end

         private
Edited by 🤖 GitLab Bot 🤖