Cli: Push fails with "Cannot read property 'success' of undefined" error when Apex file names do not match

Created on 15 Oct 2020  Â·  3Comments  Â·  Source: forcedotcom/cli

Summary

When Apex class .cls and .cls-meta.xml file names do not match, CLI push will fail with the following error:

ERROR running force:source:push:  Cannot read property 'success' of undefined

Steps To Reproduce:

sfdx force:org:create -s -a demo -f config/project-scratch-def.json
cd demo
sfdx force:apex:class:create -n Demo -d force-app/main/default/classes
mv force-app/main/default/classes/Hello.cls force-app/main/default/classes/HelloFAIL.cls
sfdx force:source:push

Expected result

We should get a clear error message telling us that the Apex file names do not match.

Actual result

sfdx force:source:push command fails with:

ERROR running force:source:push:  Cannot read property 'success' of undefined

Additional information

I could reproduce the issue on the release and prerelease of the CLI.

bug

Most helpful comment

I have a fix for this in review and assuming everything checks out it will be included in the release this Saturday. Thanks @pozil

All 3 comments

Same thing happens when .cls-meta.xml is missing

I have a fix for this in review and assuming everything checks out it will be included in the release this Saturday. Thanks @pozil

This is now fixed with CLI version 7.76.1 and salesforcedx plugin version 50.1.1

Was this page helpful?
0 / 5 - 0 ratings