From 35dfd75ef5db5d8d4f53af6c922c8f7fd3e528fa Mon Sep 17 00:00:00 2001 From: jNullj <15849761+jNullj@users.noreply.github.com> Date: Wed, 14 Jun 2023 22:53:48 +0300 Subject: [PATCH] Fix: [GithubCommitActivity] invalid branch error handling (#9258) * Fix error handling of bad branch in [GithubCommitActivity] When GraphQL response with a bad repo it returns an error indicating the bad repo. When GraphQL has the currect repo with a bad branch it will null inside the repo object without an error object. The privouse commits seems to try and use that but due not allowing null in schema it did not work and an error due to bad schema would show insted. This commit fixes this issue * Add test for invalid branch in [GithubCommitActivity] --------- Co-authored-by: jNullj --- services/github/github-commit-activity.service.js | 2 +- services/github/github-commit-activity.tester.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/services/github/github-commit-activity.service.js b/services/github/github-commit-activity.service.js index 39af8a2f12f55..ca270a19cfb41 100644 --- a/services/github/github-commit-activity.service.js +++ b/services/github/github-commit-activity.service.js @@ -13,7 +13,7 @@ const schema = Joi.object({ history: Joi.object({ totalCount: nonNegativeInteger, }).required(), - }), + }).allow(null), }).required(), }).required(), }).required() diff --git a/services/github/github-commit-activity.tester.js b/services/github/github-commit-activity.tester.js index 0bc8a7ef1371a..bf99826fc55ae 100644 --- a/services/github/github-commit-activity.tester.js +++ b/services/github/github-commit-activity.tester.js @@ -52,3 +52,10 @@ t.create('commit activity (repo not found)') label: 'commit activity', message: 'repo not found', }) + +t.create('commit activity (invalid branch)') + .get('/w/badges/shields/invalidBranchName.json') + .expectBadge({ + label: 'commit activity', + message: 'invalid branch', + })