diff --git a/package.json b/package.json index 687dbc5..5e06c6a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@adobe/aio-lib-runtime", - "version": "7.1.6", + "version": "7.1.7", "license": "Apache-2.0", "main": "src/index.js", "bugs": { diff --git a/src/utils.js b/src/utils.js index b810721..8f5df7e 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1731,7 +1731,7 @@ async function findProjectHashOnServer (ow, projectName) { // check for package with the projectName in manifest File and if found -> return the projectHash on the server const resultSync = await ow.packages.list(options) for (const pkg of resultSync) { - if (pkg.annotations.length > 0) { + if (pkg.annotations?.length > 0) { const whiskManaged = pkg.annotations.find(elem => elem.key === 'whisk-managed') if (whiskManaged !== undefined && whiskManaged.value.projectName === projectName) { projectHash = whiskManaged.value.projectHash @@ -1742,7 +1742,7 @@ async function findProjectHashOnServer (ow, projectName) { // if no package exists with the projectName -> look in actions const resultActionList = await ow.actions.list() for (const action of resultActionList) { - if (action.annotations.length > 0) { + if (action.annotations?.length > 0) { const whiskManaged = action.annotations.find(elem => elem.key === 'whisk-managed') if (whiskManaged !== undefined && whiskManaged.value.projectName === projectName) { projectHash = whiskManaged.value.projectHash @@ -1754,7 +1754,7 @@ async function findProjectHashOnServer (ow, projectName) { // if no action exists with the projectName -> look in triggers const resultTriggerList = await ow.triggers.list() for (const trigger of resultTriggerList) { - if (trigger.annotations.length > 0) { + if (trigger.annotations?.length > 0) { const whiskManaged = trigger.annotations.find(elem => elem.key === 'whisk-managed') if (whiskManaged !== undefined && whiskManaged.value.projectName === projectName) { projectHash = whiskManaged.value.projectHash @@ -1766,7 +1766,7 @@ async function findProjectHashOnServer (ow, projectName) { // if no trigger exists with the projectName -> look in rules const resultRules = await ow.rules.list() for (const rule of resultRules) { - if (rule.annotations.length > 0) { + if (rule.annotations?.length > 0) { const whiskManaged = rule.annotations.find(elem => elem.key === 'whisk-managed') if (whiskManaged !== undefined && whiskManaged.value.projectName === projectName) { diff --git a/test/utils.test.js b/test/utils.test.js index 9aad044..fd92496 100644 --- a/test/utils.test.js +++ b/test/utils.test.js @@ -1936,6 +1936,20 @@ describe('getProjectHash', () => { }) describe('findProjectHashOnServer', () => { + test('default projectHash (null annotations in packages, actions, triggers, rules)', async () => { + const testProjectName = 'ThisIsTheNameOfTheProject' + const pkgList = ow.mockResolved('packages.list', [{ annotations: null }]) + const actList = ow.mockResolved('actions.list', [{ annotations: null }]) + const trgList = ow.mockResolved('triggers.list', [{ annotations: null }]) + const rlzList = ow.mockResolved('rules.list', [{ annotations: null }]) + const result = await utils.findProjectHashOnServer(ow, testProjectName) + expect(pkgList).toHaveBeenCalled() + expect(actList).toHaveBeenCalled() + expect(trgList).toHaveBeenCalled() + expect(rlzList).toHaveBeenCalled() + expect(result).toBe('') + }) + test('default projectHash (no packages, actions, triggers, rules found)', async () => { const testProjectName = 'ThisIsTheNameOfTheProject' const pkgList = ow.mockResolved('packages.list', '')