Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix #42: truncate too long descriptions #67

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions github_jira_sync_app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ def merge_dicts(d1, d2):
d1[key] = d2[key]


def truncate_description(s):
"""Jira has a limitation of 23000 characters for description. Truncate to avoid API error."""
if len(s) > 28000:
return (
s[:28000]
+ "..."
+ "\n Text exceeded Jira maximum length. Please see the original issue for details."
)
return s


def verify_signature(payload_body, secret_token, signature_header):
"""Verify that the payload was sent from GitHub by validating SHA256.

Expand Down Expand Up @@ -235,6 +246,7 @@ async def bot(request: Request, payload: dict = Body(...)):

issue_body = gh_issue.body if settings["sync_description"] else ""
if issue_body:
issue_body = truncate_description(issue_body)
doc = Document(issue_body)
issue_body = jira_text_renderer.render(doc)

Expand Down
Loading