The entered text is too long

We have a Sync error for TSS-6578 that is constantly blocking Exalate with Error Detail Message “Could not add a comment to an an issue with id ‘55,722’:The comment can not be created due to: comment => The entered text is too long. It exceeds the allowed limit of 32767 characters.”

In Jira Cloud the default character limit is 32767. When a comment longer than this is encountered during synchronization, Exalate is unable to create it, resulting in a blocking error.

To address this and prevent future sync failures caused by comments exceeding this limit, you can use the script below to truncate comments to a size within the limit.

Incoming sync Jira Cloud

issue.comments = commentHelper.mergeComments(issue, replica, { it.body = it.body.take(32700); it })

Hi Javier,

Rather than truncate the comment - potentially missing out vital information, is it possible for Exalate to split up the incoming comment and post each segment as a separate comment?

Yes that should be very possible, I recently recommended something similar here:

Please take a quick look and let me know if you need a hand.

Thanks
Majid

Hey @Kevin – we’ve been running into the same max chars error. Do you know how we’d implement Majid’s block of code while also applying the solution you shared for addressing the GitHub Flavored Markdown conversion? i.e. issue.description = nodeHelper.toMarkDownFromHtml(replica.description)

Update: Using something more along the lines of what Javier recommended (i.e. truncating the description on the Jira side) should also work fine for us since folks can just jump back to the GitHub issue if they need to see the entire description text.

Thanks!

Joe

Hi @jcotant

Just wanted to check/confirm that there are 2 scenarios on your end:

-On jira side, you are having max character issue

-The mardown convesion on Jira side.

My understanding is that you want to combine the 2 logics, correct?

Hi Jillani,

That’s correct – Kevin helped provide a solution for addressing the GitHub Flavored Markdown conversion from GitHub to Jira.

I’d love to understand how I can keep the solution Kevin suggested and combine it with Javier and/or Majid’s code.

Best,
Joe

Hi @jcotant

Thank you for the confirmation. I tested the following snippet in the incoming of both Jira platforms (Cloud and on-prem) after combining the two logics, and it worked for me, please check and let me know the outcome:

/*
 * -------------------------------------------------------------------------
 * ROBUST LOGIC FOR DESCRIPTION HANDLING
 * -------------------------------------------------------------------------
 */
 
def finalDescription = null

if (replica.description) {
    try {
        finalDescription = nodeHelper.toJiraWikiFromMarkdown(replica.description)
    } catch (MissingMethodException ex) {
        log.warn("Function 'toJiraWikiFromMarkdown' not found. Falling back to raw Markdown.")
        finalDescription = replica.description
    }
}

if (finalDescription?.length() >= 32768) {
  issue.description = finalDescription.take(32767)
  def overflowText = finalDescription.substring(32767)
  if (overflowText) {
    def overflowComment = "Continuation of description due to Jira character limitations:\n" + overflowText
    issue.comments = commentHelper.addComment(overflowComment, issue.comments)
  }
} else {
  issue.description = finalDescription
}


// This line MUST come AFTER the description logic to properly merge all comments
issue.comments    = commentHelper.mergeComments(issue, replica, { it.body = it.body.take(32700); it })

Hi Jillani,

Thanks very much for the help on this one. Unfortunately that code did not retain the GitHub Flavored Markdown conversion to Jira (the formatting was jumbled) and the description didn’t appear to spill over to the comments.

Would it be possible to try Javier’s solution where the description length is maxed out at 32700 characters in Jira? Seems like that one might be simpler to implement (especially if we need to include the toMarkDownFromHtml syntax?). I can just educate our teams on going to the GitHub issue for any issues where the entire description can’t be populated in Jira.

Thanks again for your continued help.

Best,

Joe

I think the issue is with above line only

can you please replace with following line?

finalDescription = nodeHelper.toMarkDownFromHtml(replica.description)

Thanks,

Sonal

Thank you @Sonal_Otwani for pointing this out.

@jcotant Please let us know the outcome.

That worked! Thanks so much, @Sonal_Otwani and @Jillani_Fazal. I’ve applied this fix to all of our active connections and will let you know if anything else arises

1 Like

Hi @jcotant

Sounds great and glad that the shared snippet along with the correction did the trick. Just for the record, sharing the amended script, which worked on your end, for the other users.


def finalDescription = null

if (replica.description) {
    try {
        finalDescription = nodeHelper.toMarkDownFromHtml(replica.description)

    } catch (MissingMethodException ex) {
        log.warn("Function 'toJiraWikiFromMarkdown' not found. Falling back to raw Markdown.")
        finalDescription = replica.description
    }
}

if (finalDescription?.length() >= 32768) {
  issue.description = finalDescription.take(32767)
  def overflowText = finalDescription.substring(32767)
  if (overflowText) {
    def overflowComment = "Continuation of description due to Jira character limitations:\n" + overflowText
    issue.comments = commentHelper.addComment(overflowComment, issue.comments)
  }
} else {
  issue.description = finalDescription
}