@@ -502,7 +502,13 @@ def update_sqlmesh_comment_info(
502502 # If we find a match against the regex then we just return since the comment has already been posted
503503 if seq_get (re .findall (dedup_regex , comment .body ), 0 ):
504504 return comment
505- comment .edit (body = f"{ comment .body } \n { value } " )
505+ full_comment = f"{ comment .body } \n { value } "
506+ body , * truncated = self ._chunk_up_api_message (f"{ full_comment } " )
507+ if truncated :
508+ logger .warning (
509+ f"Comment body was too long so we truncated it. Full text: { full_comment } "
510+ )
511+ comment .edit (body = body )
506512 return comment
507513
508514 def update_pr_environment (self ) -> None :
@@ -579,15 +585,10 @@ def _update_check(
579585 kwargs ["completed_at" ] = current_time
580586 if conclusion :
581587 kwargs ["conclusion" ] = conclusion .value
582- full_summary_bytes = (full_summary or title ).encode ("utf-8" )
583- summary , text , * truncated = [
584- full_summary_bytes [i : i + self .MAX_BYTE_LENGTH ].decode ("utf-8" , "ignore" )
585- for i in range (0 , len (full_summary_bytes ), self .MAX_BYTE_LENGTH )
586- ] + [None ]
588+ full_summary = full_summary or title
589+ summary , text , * truncated = self ._chunk_up_api_message (full_summary ) + [None ]
587590 if truncated and truncated [0 ] is not None :
588- logger .warning (
589- f'Summary was too long so we truncated it. Full text: { full_summary_bytes .decode ("utf-8" , "ignore" )} '
590- )
591+ logger .warning (f"Summary was too long so we truncated it. Full text: { full_summary } " )
591592 kwargs ["output" ] = {"title" : title , "summary" : summary }
592593 if text :
593594 kwargs ["output" ]["text" ] = text
@@ -924,3 +925,13 @@ def get_command_from_comment(self) -> BotCommand:
924925 return BotCommand .from_comment_body (
925926 self ._event .pull_request_comment_body , self .bot_config .command_namespace
926927 )
928+
929+ def _chunk_up_api_message (self , message : str ) -> t .List [str ]:
930+ """
931+ Chunks up the message into `MAX_BYTE_LENGTH` byte chunks
932+ """
933+ message_encoded = message .encode ("utf-8" )
934+ return [
935+ message_encoded [i : i + self .MAX_BYTE_LENGTH ].decode ("utf-8" , "ignore" )
936+ for i in range (0 , len (message_encoded ), self .MAX_BYTE_LENGTH )
937+ ]
0 commit comments