@W-19835755 - Detect custom LWC cross-namespace risks#483
@W-19835755 - Detect custom LWC cross-namespace risks#483sf-IrfanAmeeer-Shaik wants to merge 7 commits into
Conversation
28392ea to
e5d14ef
Compare
| "loglevelFlagDeprecated": "loglevel is deprecated. Use --verbose instead", | ||
| "cleanupMetadataTablesRequired": "Omnistudio configuration tables contain records. Back up your Omnistudio component table data, and manually clean up the Omnistudio configuration tables. <a href='https://help.salesforce.com/s/articleView?id=xcloud.os_enable_omnistudio_metadata_api_support.htm&type=5' target='_blank'>Learn more about cleaning up tables in Salesforce Help</a>" | ||
| "cleanupMetadataTablesRequired": "Omnistudio configuration tables contain records. Back up your Omnistudio component table data, and manually clean up the Omnistudio configuration tables. <a href='https://help.salesforce.com/s/articleView?id=xcloud.os_enable_omnistudio_metadata_api_support.htm&type=5' target='_blank'>Learn more about cleaning up tables in Salesforce Help</a>", | ||
| "customLwcCrossNamespaceWarning": "Embeds LWC '%s' (%s). After migration the auto-generated %s LWC retains the vertical namespace while this LWC moves to c/ — cross-reference error at runtime. Workaround: use omnistudio-standard-runtime-wrapper or enable Lightning Web Security." |
There was a problem hiding this comment.
Is this label UX Approved ?
| * - 'custom': User-defined custom LWC | ||
| */ | ||
| protected async getLwcClassifications(): Promise<Map<string, string>> { | ||
| const lwcMap = new Map<string, string>(); |
There was a problem hiding this comment.
interface LwcBundleRecord {
DeveloperName?: string;
NamespacePrefix?: string;
}
| const lwcMap = new Map<string, string>(); | ||
| try { | ||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call | ||
| const result = await ( |
There was a problem hiding this comment.
| const result = await ( | |
| let result = await this.connection.tooling.query<LwcBundleRecord>( | |
| 'SELECT Id, DeveloperName, NamespacePrefix FROM LightningComponentBundle' | |
| ); | |
| const allRecords: LwcBundleRecord[] = [...(result.records ?? [])]; | |
| while (!result.done && result.nextRecordsUrl) { | |
| result = await this.connection.tooling.queryMore<LwcBundleRecord>(result.nextRecordsUrl); | |
| allRecords.push(...(result.records ?? [])); | |
| } |
| ]; | ||
|
|
||
| // Check for cross-namespace LWC embeds | ||
| const lwcMap = await this.getLwcClassifications(); |
There was a problem hiding this comment.
This will be called in loop for n number of flexcards. we can move it processCardComponents ?
| "skippingTruncation": "Skipping truncation as the org is on standard data model.", | ||
| "loglevelFlagDeprecated": "loglevel is deprecated. Use --verbose instead." | ||
| "loglevelFlagDeprecated": "loglevel is deprecated. Use --verbose instead.", | ||
| "customLwcCrossNamespaceWarning": "Embeds LWC '%s' (%s). After migration the auto-generated %s LWC retains the vertical namespace while this LWC moves to c/ — cross-reference error at runtime. Workaround: use omnistudio-standard-runtime-wrapper or enable Lightning Web Security." |
There was a problem hiding this comment.
Same UX Approved
| if (ns) continue; // Skip managed packages | ||
|
|
||
| let kind: string; | ||
| if (/^cf[a-z0-9]/i.test(name)) { |
There was a problem hiding this comment.
can we have flexcard which is prefixed with cf and its not generated ?
There was a problem hiding this comment.
There can be LWC that has cf prefix and uploaded into the org and is not a flexcard. It is not possible to have a non generated flexcard in managed package.
| if (!lwcName) continue; | ||
|
|
||
| const kind = lwcMap.get(lwcName.toLowerCase()); | ||
| if (kind !== undefined) { |
There was a problem hiding this comment.
this error should be only for custom correct ?
|
|
||
| const lwcName: string = propertySet['lwcName'] || ''; | ||
| const kind = lwcName ? lwcMap.get(lwcName.toLowerCase()) : undefined; | ||
| if (kind !== undefined) { |
There was a problem hiding this comment.
Same warning should be only for custom correct ?
| const walkChildren = (children: any[]) => { | ||
| for (const child of children || []) { | ||
| if (child.element === 'customLwc') { | ||
| const lwcName: string = (child.property?.customlwcname || '').toLowerCase(); |
| // Check lwcName field | ||
| const lwcName: string = propertySet['lwcName'] || ''; | ||
| if (lwcName) { | ||
| const kind = lwcMap.get(lwcName.toLowerCase()); |
There was a problem hiding this comment.
Code repeated multiple times. Move it to method
| const lwcName: string = propertySet['lwcName'] || ''; | ||
| if (lwcName) { | ||
| const kind = lwcMap.get(lwcName.toLowerCase()); | ||
| if (kind === 'custom') { |
There was a problem hiding this comment.
Keep DRY
rajender-kumar-salesforce
left a comment
There was a problem hiding this comment.
Take Approval from UX for labels
| "apexClassNotFound": "Apex class \"%s\" referenced in \"%s\" does not exist in the org", | ||
| "cleanupMetadataTablesRequired": "Omnistudio configuration tables contain records. Back up your Omnistudio component table data, and manually clean up the Omnistudio configuration tables. <a href='https://help.salesforce.com/s/articleView?id=xcloud.os_enable_omnistudio_metadata_api_support.htm&type=5' target='_blank'>Learn more about cleaning up tables in Salesforce Help</a>" | ||
| "cleanupMetadataTablesRequired": "Omnistudio configuration tables contain records. Back up your Omnistudio component table data, and manually clean up the Omnistudio configuration tables. <a href='https://help.salesforce.com/s/articleView?id=xcloud.os_enable_omnistudio_metadata_api_support.htm&type=5' target='_blank'>Learn more about cleaning up tables in Salesforce Help</a>", | ||
| "customLwcCrossNamespaceWarning": "Embeds LWC '%s' (%s). After migration, the auto-generated %s LWC retains the vertical namespace while this LWC moves to c/, causing a cross-reference error at runtime. To resolve this, use the Omnistudio standard wrapper or enable Lightning Web Security." |
There was a problem hiding this comment.
is this CX reviewed?


What does this PR do?
Adds warnings for FlexCards and OmniScripts that embed custom LWCs. After migration, the auto-generated FlexCard/OmniScript LWCs keep the vertical namespace (like
vlocity_ins__) but any custom LWCs inside them move toc/, which breaks at runtime with cross-reference errors.Now the assess and migrate commands will flag these cases and suggest using
omnistudio-standard-runtime-wrapperor enabling Lightning Web Security as a workaround.What changed:
getLwcClassifications()in base.ts to query Tooling API and figure out which LWCs are custom vs auto-generatedWhat issues does this PR fix or reference?
Fixes W-19835755 - the Prudential cross-reference error issue where FlexCards/OmniScripts with custom LWCs fail post-migration.
Assesmode: