function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Patson Settachatgul 7Patson Settachatgul 7 

DX force:source:pull Cannot read property 'fileName' of undefined

I'm running on windows 10, sfdx version 6.1.19, and getting an error when I try to pull source froma scratch org.  I feel like I've tracked it down to some code in node_modules\sfdx-cli\node_modules\salesforce-alm\dist\lib\typeDefUtil.js  which seems to assume a POSIX path seperator.  The parameter auraBundleFileProperties is an array of objects representing file properties.  The fullName property doesn't seem consistent in what path separator is being used.  Sometimes it's '/', Sometimes it's '\' -- I was able to solve the issue by changing the line

            const parentBundle = auraBundleFileProperties.find(fileProperty => fileProperty.fullName.split(path.sep)[0] === bundleName);

to

            const parentBundle = auraBundleFileProperties.find(fileProperty => path.normalize(fileProperty.fullName).split(path.sep)[0] === bundleName);

That seemed to work, but I've obviously hacked the original code delivered by SF... Has anyone else run into this issue?

The function was originally written as...
static getDefaultAggregateMetadataPath(devName, typeDef, defaultSrcDir, metadataRegistry, auraBundleFileProperties) {
        let metadataPath;
        const defaultTypeDir = !util.isNullOrUndefined(typeDef.defaultDirectory) ?
            path.join(defaultSrcDir, typeDef.defaultDirectory) : defaultSrcDir;
        if (typeDef.metadataName === metadataRegistry.typeDefs.AuraDefinitionBundle.metadataName) {
            const bundleName = devName.split(path.sep)[0];
            const parentBundle = auraBundleFileProperties.find(fileProperty => fileProperty.fullName.split(path.sep)[0] === bundleName);
            const fileName = `${path.basename(parentBundle.fileName)}${metadataRegistry.metadataFileExt}`;
            metadataPath = path.join(defaultTypeDir, bundleName, fileName);
        }
       .... more code.....
}
Stuart Neilson 1Stuart Neilson 1
Hi

I have same issue Cannot read property 'fileName' of undefined
Greg FinzerGreg Finzer
I have the same issue.