From 7c2eec68a609c48b21aee537020a00d6d5884891 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Tue, 17 May 2022 18:43:38 +0100 Subject: [PATCH 1/4] more verbose logging on publish:github error Signed-off-by: Brian Fletcher --- .../actions/builtin/publish/github.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts index 340eb06dcd..2e5fc2091f 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts @@ -263,7 +263,22 @@ export function createPublishGithubAction(options: { allow_rebase_merge: allowRebaseMerge, }); - const { data: newRepo } = await repoCreationPromise; + let newRepo; + + try { + newRepo = (await repoCreationPromise).data; + } catch (e) { + assertError(e); + if (e.message === 'Resource not accessible by integration') { + ctx.logger.warn( + 'The GitHub app or token provided to Backstage may not have the required permissions to create the repository.', + ); + } + throw new Error( + `Failed to create the ${user.data.type} repository ${owner}/${repo}: ${e.message}`, + ); + } + if (access?.startsWith(`${owner}/`)) { const [, team] = access.split('/'); await client.rest.teams.addOrUpdateRepoPermissionsInOrg({ From 6901f6be4abb6a4d2d9dce777bd11aeeead22e4d Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Tue, 17 May 2022 18:49:32 +0100 Subject: [PATCH 2/4] add changeset Signed-off-by: Brian Fletcher --- .changeset/spotty-goats-look.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/spotty-goats-look.md diff --git a/.changeset/spotty-goats-look.md b/.changeset/spotty-goats-look.md new file mode 100644 index 0000000000..0759afcd57 --- /dev/null +++ b/.changeset/spotty-goats-look.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +--- + +Adds more of an explanation when the `publish:github` scaffolder action fails to create a repository. From 1aad5b38219b13cd405b62bed036ff18866496d8 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Wed, 18 May 2022 10:32:09 +0100 Subject: [PATCH 3/4] add repository and user type to error message Signed-off-by: Brian Fletcher --- .../src/scaffolder/actions/builtin/publish/github.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts index 2e5fc2091f..f238314534 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts @@ -271,7 +271,7 @@ export function createPublishGithubAction(options: { assertError(e); if (e.message === 'Resource not accessible by integration') { ctx.logger.warn( - 'The GitHub app or token provided to Backstage may not have the required permissions to create the repository.', + `The GitHub app or token provided may not have the required permissions to create the ${user.data.type} repository ${owner}/${repo}.`, ); } throw new Error( From 7a9ce63e928e38ad38521a2393c26cb31860140f Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Wed, 18 May 2022 11:07:51 +0100 Subject: [PATCH 4/4] Colon to comma in error message :->, Signed-off-by: Brian Fletcher --- .../src/scaffolder/actions/builtin/publish/github.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts index f238314534..1f9125d962 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts @@ -275,7 +275,7 @@ export function createPublishGithubAction(options: { ); } throw new Error( - `Failed to create the ${user.data.type} repository ${owner}/${repo}: ${e.message}`, + `Failed to create the ${user.data.type} repository ${owner}/${repo}, ${e.message}`, ); }