RFR: 1707: Bot warns about "No .jcheck/conf found" when it should not

Erik Joelsson erikj at openjdk.org
Mon Dec 5 22:19:07 UTC 2022


On Mon, 5 Dec 2022 21:58:43 GMT, Zhao Song <zsong at openjdk.org> wrote:

> In [SKARA-1393](https://bugs.openjdk.org/browse/SKARA-1393), I added some checks to ensure the target branch of a pr contains valid jcheck configuration. This change went live on November 28, however, some users found that the warning of "No .jcheck/conf found" printed after they integrated their pr. After more investigation, I am thinking it's maybe a GitLab bug. Since when the issue happens, GitLab will always return "Commit Not Found", so we could have a temporary workaround right now.
> 
> For GitLab REST API:
> If commit not found, it will return "404 Commit Not Found"
> 
> If file not found it will return "404 File Not Found"
> 
> For Github REST API:
> If commit not found, it will return "No commit found for the ref "
> 
> If file not found it will return "Not found"

I think this is good enough for now, but as we talked about offline, we should follow up with changing the signature of `HostedRepository::fileContents` so that it returns an Optional instead. That Optional should only be empty on 404 File Not Found and any other error should throw an exception.

bots/pr/src/main/java/org/openjdk/skara/bots/pr/LimitedCensusInstance.java line 77:

> 75:         } catch (UncheckedRestException e) {
> 76:             // Throw the exception if the error is not exactly "File not found"
> 77:             if (e.getStatusCode() != 404 || e.getBody().contains("Commit Not Found") || e.getBody().contains("No commit found")) {

We should check for precisely "File Not Found" or "Not found".

Suggestion:

            if (e.getStatusCode() != 404 || (!e.getBody().equals("File Not Found") && !e.getBody().equals("Not found"))) {

-------------

PR: https://git.openjdk.org/skara/pull/1435


More information about the skara-dev mailing list