Skip to content

@W-19835755 - Detect custom LWC cross-namespace risks#483

Open
sf-IrfanAmeeer-Shaik wants to merge 7 commits into
developfrom
feature/w-19835755-custom-lwc-detection
Open

@W-19835755 - Detect custom LWC cross-namespace risks#483
sf-IrfanAmeeer-Shaik wants to merge 7 commits into
developfrom
feature/w-19835755-custom-lwc-detection

Conversation

@sf-IrfanAmeeer-Shaik
Copy link
Copy Markdown
Collaborator

@sf-IrfanAmeeer-Shaik sf-IrfanAmeeer-Shaik commented May 15, 2026

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 to c/, which breaks at runtime with cross-reference errors.

Now the assess and migrate commands will flag these cases and suggest using omnistudio-standard-runtime-wrapper or enabling Lightning Web Security as a workaround.

What changed:

  • Added getLwcClassifications() in base.ts to query Tooling API and figure out which LWCs are custom vs auto-generated
  • Added detection logic in FlexCard and OmniScript tools to scan for embedded custom LWCs during both assessment and migration
  • New warning message points users to the workaround

What 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:

image image

@sf-IrfanAmeeer-Shaik sf-IrfanAmeeer-Shaik requested a review from a team as a code owner May 15, 2026 02:58
@sf-IrfanAmeeer-Shaik sf-IrfanAmeeer-Shaik changed the base branch from main to develop May 15, 2026 03:00
@sf-IrfanAmeeer-Shaik sf-IrfanAmeeer-Shaik force-pushed the feature/w-19835755-custom-lwc-detection branch from 28392ea to e5d14ef Compare May 15, 2026 03:59
Comment thread messages/assess.json Outdated
"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."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this label UX Approved ?

Comment thread src/migration/base.ts
* - 'custom': User-defined custom LWC
*/
protected async getLwcClassifications(): Promise<Map<string, string>> {
const lwcMap = new Map<string, string>();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interface LwcBundleRecord {
DeveloperName?: string;
NamespacePrefix?: string;
}

Comment thread src/migration/base.ts
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 (
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 ?? []));
}

Comment thread src/migration/flexcard.ts Outdated
];

// Check for cross-namespace LWC embeds
const lwcMap = await this.getLwcClassifications();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be called in loop for n number of flexcards. we can move it processCardComponents ?

Comment thread messages/migrate.json Outdated
"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."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same UX Approved

Comment thread src/migration/base.ts
if (ns) continue; // Skip managed packages

let kind: string;
if (/^cf[a-z0-9]/i.test(name)) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have flexcard which is prefixed with cf and its not generated ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/migration/omniscript.ts Outdated
if (!lwcName) continue;

const kind = lwcMap.get(lwcName.toLowerCase());
if (kind !== undefined) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this error should be only for custom correct ?

Comment thread src/migration/omniscript.ts Outdated

const lwcName: string = propertySet['lwcName'] || '';
const kind = lwcName ? lwcMap.get(lwcName.toLowerCase()) : undefined;
if (kind !== undefined) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same warning should be only for custom correct ?

Comment thread src/migration/flexcard.ts
const walkChildren = (children: any[]) => {
for (const child of children || []) {
if (child.element === 'customLwc') {
const lwcName: string = (child.property?.customlwcname || '').toLowerCase();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only path where custom lwc can be referenced ? Found these with claude. can you check it ?

Image Image

Comment thread src/migration/omniscript.ts Outdated
// Check lwcName field
const lwcName: string = propertySet['lwcName'] || '';
if (lwcName) {
const kind = lwcMap.get(lwcName.toLowerCase());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code repeated multiple times. Move it to method

Comment thread src/migration/omniscript.ts Outdated
const lwcName: string = propertySet['lwcName'] || '';
if (lwcName) {
const kind = lwcMap.get(lwcName.toLowerCase());
if (kind === 'custom') {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep DRY

Copy link
Copy Markdown
Collaborator

@rajender-kumar-salesforce rajender-kumar-salesforce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take Approval from UX for labels

Comment thread messages/assess.json
"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."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this CX reviewed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants