diff options
author | Zuul <zuul@review.opendev.org> | 2023-03-22 21:51:53 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2023-03-22 21:51:53 +0000 |
commit | 286677584a5adec8fd2511829ecbcbc6bb1feb11 (patch) | |
tree | 729022dcc7854ae0f465159c612ebf50d9c50aa3 /zuul/driver/github/githubconnection.py | |
parent | 420fa0a6a747f4c5a505782f7869b9e52e3f8289 (diff) | |
parent | b372575b62158b89ef608c8a556f433f15c3375a (diff) | |
download | zuul-286677584a5adec8fd2511829ecbcbc6bb1feb11.tar.gz |
Merge "Truncate Github file annotation message to 64 KB"
Diffstat (limited to 'zuul/driver/github/githubconnection.py')
-rw-r--r-- | zuul/driver/github/githubconnection.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/zuul/driver/github/githubconnection.py b/zuul/driver/github/githubconnection.py index cffbd6769..f5f81fcdb 100644 --- a/zuul/driver/github/githubconnection.py +++ b/zuul/driver/github/githubconnection.py @@ -81,6 +81,10 @@ ANNOTATION_LEVELS = { "warning": "warning", "error": "failure", } +# The maximum size for the 'message' field is 64 KB. Since it's unclear +# from the Github docs if the unit is KiB or KB we'll use KB to be on +# the safe side. +ANNOTATION_MAX_MESSAGE_SIZE = 64 * 1000 EventTuple = collections.namedtuple( "EventTuple", [ @@ -2432,7 +2436,9 @@ class GithubConnection(ZKChangeCacheMixin, ZKBranchCacheMixin, BaseConnection): raw_annotation = { "path": fn, "annotation_level": annotation_level, - "message": comment["message"], + "message": comment["message"].encode( + "utf8")[:ANNOTATION_MAX_MESSAGE_SIZE].decode( + "utf8", "ignore"), "start_line": start_line, "end_line": end_line, "start_column": start_column, |