From fe569fc53f5d6c1aa7a07b35c63f986d6ae43f34 Mon Sep 17 00:00:00 2001 From: David Hasani Date: Mon, 6 Oct 2025 15:27:12 -0700 Subject: [PATCH 1/3] update YAML --- .../transformByQ/transformFileHandler.ts | 21 ++++++++++++++----- .../commands/transformByQ.test.ts | 10 +++++++-- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/packages/core/src/codewhisperer/service/transformByQ/transformFileHandler.ts b/packages/core/src/codewhisperer/service/transformByQ/transformFileHandler.ts index 91ee8f6639c..b16ea64022c 100644 --- a/packages/core/src/codewhisperer/service/transformByQ/transformFileHandler.ts +++ b/packages/core/src/codewhisperer/service/transformByQ/transformFileHandler.ts @@ -139,8 +139,14 @@ export function validateCustomVersionsFile(fileContents: string) { getLogger().info('CodeTransformation: .YAML file must contain at least dependencies or plugins') return `YAML file must contain at least \`dependencies\` or \`plugins\` under \`dependencyManagement\`` } - for (const item of dependenciesAndPlugins) { - const errorMessage = validateItem(item) + for (const item of dependencies) { + const errorMessage = validateItem(item, false) + if (errorMessage) { + return errorMessage + } + } + for (const item of plugins) { + const errorMessage = validateItem(item, true) if (errorMessage) { return errorMessage } @@ -153,10 +159,15 @@ export function validateCustomVersionsFile(fileContents: string) { } // return an error message, or undefined if item is valid -function validateItem(item: any, validOriginTypes: string[] = ['FIRST_PARTY', 'THIRD_PARTY']) { - if (!/^[^\s:]+:[^\s:]+$/.test(item.identifier)) { +function validateItem(item: any, isPlugin: boolean) { + const validOriginTypes = ['FIRST_PARTY', 'THIRD_PARTY'] + if (!isPlugin && !/^[^\s:]+:[^\s:]+$/.test(item.identifier)) { getLogger().info(`CodeTransformation: Invalid identifier format: ${item.identifier}`) - return `Invalid identifier format: \`${item.identifier}\`. Must be in format \`groupId:artifactId\` without spaces` + return `Invalid dependency identifier format: \`${item.identifier}\`. Must be in format \`groupId:artifactId\` without spaces` + } + if (isPlugin && !item.identifier?.trim()) { + getLogger().info('CodeTransformation: Missing identifier in plugin') + return 'Missing `identifier` in plugin' } if (!validOriginTypes.includes(item.originType)) { getLogger().info(`CodeTransformation: Invalid originType: ${item.originType}`) diff --git a/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts b/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts index f205f075872..7a5cd2f599a 100644 --- a/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts +++ b/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts @@ -65,7 +65,7 @@ dependencyManagement: targetVersion: "3.0.0" originType: "THIRD_PARTY" plugins: - - identifier: "com.example:plugin" + - identifier: "plugin.id" targetVersion: "1.2.0" versionProperty: "plugin.version" # Optional originType: "FIRST_PARTY" # or "THIRD_PARTY"` @@ -582,7 +582,7 @@ dependencyManagement: assert.strictEqual(errorMessage, `Missing required key: \`dependencyManagement\``) }) - it(`WHEN validateCustomVersionsFile on .yaml file with invalid identifier format THEN fails validation`, function () { + it(`WHEN validateCustomVersionsFile on .yaml file with invalid dependency identifier format THEN fails validation`, function () { const invalidFile = validCustomVersionsFile.replace('com.example:library1', 'com.example-library1') const errorMessage = validateCustomVersionsFile(invalidFile) assert.strictEqual( @@ -591,6 +591,12 @@ dependencyManagement: ) }) + it(`WHEN validateCustomVersionsFile on .yaml file with missing plugin identifier format THEN fails validation`, function () { + const invalidFile = validCustomVersionsFile.replace('plugin.id', '""') + const errorMessage = validateCustomVersionsFile(invalidFile) + assert.strictEqual(errorMessage, 'Missing `identifier` in plugin') + }) + it(`WHEN validateCustomVersionsFile on .yaml file with invalid originType THEN fails validation`, function () { const invalidFile = validCustomVersionsFile.replace('FIRST_PARTY', 'INVALID_TYPE') const errorMessage = validateCustomVersionsFile(invalidFile) From 0833a619ee2ad524ffc2b316e09ab9bdc62cab02 Mon Sep 17 00:00:00 2001 From: David Hasani Date: Mon, 6 Oct 2025 15:39:29 -0700 Subject: [PATCH 2/3] fix test --- .../core/src/test/codewhisperer/commands/transformByQ.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts b/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts index 7a5cd2f599a..4e8e96ede2c 100644 --- a/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts +++ b/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts @@ -587,7 +587,7 @@ dependencyManagement: const errorMessage = validateCustomVersionsFile(invalidFile) assert.strictEqual( errorMessage, - `Invalid identifier format: \`com.example-library1\`. Must be in format \`groupId:artifactId\` without spaces` + `Invalid dependency identifier format: \`com.example-library1\`. Must be in format \`groupId:artifactId\` without spaces` ) }) From 53e9845d030c9168fb922c92c6550e18cc08303e Mon Sep 17 00:00:00 2001 From: David Hasani Date: Mon, 6 Oct 2025 16:02:22 -0700 Subject: [PATCH 3/3] fix test again --- .../core/src/test/codewhisperer/commands/transformByQ.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts b/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts index 4e8e96ede2c..3b12fcefbc0 100644 --- a/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts +++ b/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts @@ -592,7 +592,7 @@ dependencyManagement: }) it(`WHEN validateCustomVersionsFile on .yaml file with missing plugin identifier format THEN fails validation`, function () { - const invalidFile = validCustomVersionsFile.replace('plugin.id', '""') + const invalidFile = validCustomVersionsFile.replace('plugin.id', '') const errorMessage = validateCustomVersionsFile(invalidFile) assert.strictEqual(errorMessage, 'Missing `identifier` in plugin') })