Update condition before calling normalizeCodeOwner
Update the condition in the ternary operator in the resolveCodeOwner function to check that match.owners isn't empty before calling normalizeCodeOwner with match.owners[0] Before this change normalizeCodeOwner could potentially throw an error during processing if the `match` object exists but the match.owners array is empty because normalizeCodeOwner will be passed `undefined` instead of the string it expects. Signed-off-by: Isabel Tomb <isabelgtomb@gmail.com>
This commit is contained in:
@@ -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.
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user