diff --git a/bin/create-docs-pr.js b/bin/create-docs-pr.js index 6db947facd..feb76d8f1c 100644 --- a/bin/create-docs-pr.js +++ b/bin/create-docs-pr.js @@ -164,9 +164,9 @@ async function getFrontMatter(tagName, frontMatterFile) { } return { - security: JSON.stringify(frontmatter.changes.security), - bugfixes: JSON.stringify(frontmatter.changes.bugfixes), - features: JSON.stringify(frontmatter.changes.features) + security: JSON.stringify(frontmatter.changes.security || []), + bugfixes: JSON.stringify(frontmatter.changes.bugfixes || []), + features: JSON.stringify(frontmatter.changes.features || []) } } diff --git a/bin/test/create-docs-pr.test.js b/bin/test/create-docs-pr.test.js index d467047e2c..9f1e652c79 100644 --- a/bin/test/create-docs-pr.test.js +++ b/bin/test/create-docs-pr.test.js @@ -74,6 +74,7 @@ tap.test('Create Docs PR script', (testHarness) => { t.test('should throw an error if there is no frontmatter', async (t) => { mockFs.readFile.yields(null, JSON.stringify({ entries: [{ version: '1.2.3', changes: [] }] })) + // eslint-disable-next-line sonarjs/no-duplicate-string const func = () => script.getFrontMatter('v2.0.0', 'changelog.json') t.rejects(func, 'Unable to find 2.0.0 entry in changelog.json') @@ -106,6 +107,29 @@ tap.test('Create Docs PR script', (testHarness) => { }) t.end() }) + + t.test('should return empty arrays if missing changes', async (t) => { + mockFs.readFile.yields( + null, + JSON.stringify({ + entries: [ + { + version: '2.0.0', + changes: {} + } + ] + }) + ) + + const result = await script.getFrontMatter('v2.0.0', 'changelog.json') + + t.same(result, { + security: '[]', + bugfixes: '[]', + features: '[]' + }) + t.end() + }) }) testHarness.test('formatReleaseNotes', (t) => { diff --git a/changelog.json b/changelog.json index 2c281aca78..5919d2c14c 100644 --- a/changelog.json +++ b/changelog.json @@ -15,6 +15,7 @@ "version": "11.23.0", "changes": { "security": [], + "bugfixes": [], "features": [ "Added support for account level governance of AI Monitoring" ] @@ -514,4 +515,4 @@ } } ] -} \ No newline at end of file +}