diff --git a/config/config.prod.yaml b/config/config.prod.yaml index 668aa10f..ae59e06f 100644 --- a/config/config.prod.yaml +++ b/config/config.prod.yaml @@ -6,6 +6,7 @@ parameters: jira_project_key: WEBEXT labels_brackets: both + jira_char_limit: 10000 - whiteboard_tag: fidedi bugzilla_user_id: tbd diff --git a/jbi/jira/service.py b/jbi/jira/service.py index 6ca06e67..b0763206 100644 --- a/jbi/jira/service.py +++ b/jbi/jira/service.py @@ -25,9 +25,6 @@ logger = logging.getLogger(__name__) - -JIRA_DESCRIPTION_CHAR_LIMIT = 32667 - JIRA_REQUIRED_PERMISSIONS = { "ADD_COMMENTS", "CREATE_ISSUES", @@ -79,7 +76,7 @@ def create_jira_issue( "summary": bug.summary, "issuetype": {"name": issue_type}, "description": markdown_to_jira( - description, max_length=JIRA_DESCRIPTION_CHAR_LIMIT + description, max_length=context.action.parameters.jira_char_limit ), "project": {"key": context.jira.project}, } @@ -134,7 +131,7 @@ def add_jira_comment(self, context: ActionContext): prefix = f"*{commenter}* commented: \n" formatted_comment = prefix + markdown_to_jira( comment.body, - max_length=JIRA_DESCRIPTION_CHAR_LIMIT - len(prefix), + max_length=context.action.parameters.jira_char_limit - len(prefix), ) issue_key = context.jira.issue @@ -317,11 +314,11 @@ def update_issue_summary(self, context: ActionContext): """Update's an issue's summary with the description of an incoming bug""" truncated_summary = context.bug.summary or "" - if len(truncated_summary) > JIRA_DESCRIPTION_CHAR_LIMIT: + if len(truncated_summary) > context.action.parameters.jira_char_limit: # Truncate on last word. - truncated_summary = truncated_summary[:JIRA_DESCRIPTION_CHAR_LIMIT].rsplit( - maxsplit=1 - )[0] + truncated_summary = truncated_summary[ + : context.action.parameters.jira_char_limit + ].rsplit(maxsplit=1)[0] return self.update_issue_field( context, field="summary", value=truncated_summary diff --git a/jbi/models.py b/jbi/models.py index 71d32b8e..4e7ef088 100644 --- a/jbi/models.py +++ b/jbi/models.py @@ -87,6 +87,7 @@ class ActionParams(BaseModel, frozen=True): jira_project_key: str steps: ActionSteps = ActionSteps() + jira_char_limit: int = 32667 jira_components: JiraComponents = JiraComponents() jira_cf_fx_points_field: str = "customfield_10037" jira_severity_field: str = "customfield_10319"