diff --git a/.changeset/wet-hounds-vanish.md b/.changeset/wet-hounds-vanish.md new file mode 100644 index 0000000000..1a74bfb08d --- /dev/null +++ b/.changeset/wet-hounds-vanish.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +--- + +Update GitHub publisher to display a more helpful error message when repository access update fails. diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/publish/github.ts b/plugins/scaffolder-backend/src/scaffolder/stages/publish/github.ts index a449eddd5d..22233ee5dc 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/publish/github.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/publish/github.ts @@ -131,25 +131,29 @@ export class GithubPublisher implements PublisherBase { const { data } = await repoCreationPromise; - if (access?.startsWith(`${owner}/`)) { - const [, team] = access.split('/'); - await client.teams.addOrUpdateRepoPermissionsInOrg({ - org: owner, - team_slug: team, - owner, - repo: name, - permission: 'admin', - }); - // no need to add access if it's the person who own's the personal account - } else if (access && access !== owner) { - await client.repos.addCollaborator({ - owner, - repo: name, - username: access, - permission: 'admin', - }); + try { + if (access?.startsWith(`${owner}/`)) { + const [, team] = access.split('/'); + await client.teams.addOrUpdateRepoPermissionsInOrg({ + org: owner, + team_slug: team, + owner, + repo: name, + permission: 'admin', + }); + // no need to add access if it's the person who own's the personal account + } else if (access && access !== owner) { + await client.repos.addCollaborator({ + owner, + repo: name, + username: access, + permission: 'admin', + }); + } + } catch (e) { + e.message = `Failed to add access to '${access}': ${e.message}`; + throw e; } - return data?.clone_url; } }