diff --git a/.changeset/twenty-laws-tie.md b/.changeset/twenty-laws-tie.md new file mode 100644 index 0000000000..a1f9e88e57 --- /dev/null +++ b/.changeset/twenty-laws-tie.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +Updated condition in resolveCodeOwner to fix a bug where normalizeCodeOwner could potentially be called with an invalid arg causing an error in CodeOwnersProcessor. diff --git a/plugins/catalog-backend/src/processors/codeowners/resolve.ts b/plugins/catalog-backend/src/processors/codeowners/resolve.ts index 675f6542aa..b0c44a8797 100644 --- a/plugins/catalog-backend/src/processors/codeowners/resolve.ts +++ b/plugins/catalog-backend/src/processors/codeowners/resolve.ts @@ -30,7 +30,9 @@ export function resolveCodeOwner( const { filepath } = parseGitUrl(catalogInfoFileUrl); const match = codeowners.matchFile(filepath, codeOwnerEntries); - return match ? normalizeCodeOwner(match.owners[0]) : undefined; + return match?.owners?.length + ? normalizeCodeOwner(match.owners[0]) + : undefined; } export function normalizeCodeOwner(owner: string) {