Skip to content

Commit 0c8dbf1

Browse files
authored
fix: bot properly deal with truncated output (#1594)
1 parent e51cd57 commit 0c8dbf1

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

sqlmesh/integrations/github/cicd/controller.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ def pull_request_comment_body(self) -> t.Optional[str]:
272272

273273
class GithubController:
274274
BOT_HEADER_MSG = "**SQLMesh Bot Info**"
275+
MAX_CHAR_LENGTH = 65535
275276

276277
def __init__(
277278
self,
@@ -533,7 +534,7 @@ def _update_check(
533534
status: GithubCheckStatus,
534535
title: str,
535536
conclusion: t.Optional[GithubCheckConclusion] = None,
536-
summary: t.Optional[str] = None,
537+
full_summary: t.Optional[str] = None,
537538
) -> None:
538539
"""
539540
Updates the status of the merge commit.
@@ -553,7 +554,16 @@ def _update_check(
553554
kwargs["completed_at"] = current_time
554555
if conclusion:
555556
kwargs["conclusion"] = conclusion.value
556-
kwargs["output"] = {"title": title, "summary": summary or title}
557+
full_summary = full_summary or title
558+
summary, text, *truncated = [
559+
full_summary[i : i + self.MAX_CHAR_LENGTH]
560+
for i in range(0, len(full_summary), self.MAX_CHAR_LENGTH)
561+
] + [None]
562+
if truncated and truncated[0] is not None:
563+
logger.warning(f"Summary was too long so we truncated it. Full text: {full_summary}")
564+
kwargs["output"] = {"title": title, "summary": summary}
565+
if text:
566+
kwargs["output"]["text"] = text
557567
if name in self._check_run_mapping:
558568
check_run = self._check_run_mapping[name]
559569
check_run.edit(
@@ -581,7 +591,7 @@ def _update_check_handler(
581591
status=status,
582592
title=title,
583593
conclusion=conclusion,
584-
summary=summary,
594+
full_summary=summary,
585595
)
586596

587597
def update_test_check(

0 commit comments

Comments
 (0)