From d78ad8a340ce2d472593ae4dc4a758d29a85bed0 Mon Sep 17 00:00:00 2001 From: Bill Collins Date: Sun, 10 Jan 2021 11:55:55 +0000 Subject: [PATCH] Truncate long text fields --- pom.xml | 2 +- .../jenkins/plugins/checks/github/GitHubChecksDetails.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 6805cd43..d6c97878 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ true - 1.2.0 + 1.3.0-rc182.e92aa81c9bc8 1.6.1 2.9.3 diff --git a/src/main/java/io/jenkins/plugins/checks/github/GitHubChecksDetails.java b/src/main/java/io/jenkins/plugins/checks/github/GitHubChecksDetails.java index c0fd670f..d070b21b 100644 --- a/src/main/java/io/jenkins/plugins/checks/github/GitHubChecksDetails.java +++ b/src/main/java/io/jenkins/plugins/checks/github/GitHubChecksDetails.java @@ -34,6 +34,8 @@ class GitHubChecksDetails { private final ChecksDetails details; + private static final int MAX_MESSAGE_SIZE_TO_CHECKS_API = 65_535; + /** * Construct with the given {@link ChecksDetails}. * @@ -171,9 +173,9 @@ public Optional getOutput() { Output output = new Output( checksOutput.getTitle().orElseThrow( () -> new IllegalArgumentException("Title of output is required but not provided")), - checksOutput.getSummary().orElseThrow( + checksOutput.getSummary(MAX_MESSAGE_SIZE_TO_CHECKS_API).orElseThrow( () -> new IllegalArgumentException("Summary of output is required but not proviede"))) - .withText(checksOutput.getText().orElse(null)); + .withText(checksOutput.getText(MAX_MESSAGE_SIZE_TO_CHECKS_API).orElse(null)); checksOutput.getChecksAnnotations().stream().map(this::getAnnotation).forEach(output::add); checksOutput.getChecksImages().stream().map(this::getImage).forEach(output::add); return Optional.of(output);