forcedotcom / cli

Salesforce CLI
https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/
BSD 3-Clause "New" or "Revised" License
494 stars 78 forks source link

ERROR running force:source:retrieve: Cannot read property 'getWorkspaceElements' of undefined #78

Closed smukov closed 5 years ago

smukov commented 5 years ago

Summary

Created a project with manifest and tried to retrieve Wave (Einstein Analytics) components in order to setup source control and CI/CD with them, however, I'm receiving an error in the output.

I am using the sample Developer Edition org provided in Trailhead, so the issue should be easy to reproduce.

Steps To Reproduce:

  1. Create a new Developer Edition org with Einstein Analytics enabled - https://developer.salesforce.com/promotions/orgs/analytics-de
  2. SFDX: Create Project with Manifest
  3. SFDX: Authorize an Org from step 1.
  4. Change the manifest/package.xml content with below
  5. Right click on package.xml and execute SFDX: Retrieve Source in Manifest from Org
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>*</members>
        <name>WaveApplication</name>
    </types>
    <types>
        <members>*</members>
        <name>WaveDashboard</name>
    </types>
    <types>
        <members>*</members>
        <name>WaveDataflow</name>
    </types>
    <types>
        <members>*</members>
        <name>WaveDataset</name>
    </types>
    <types>
        <members>*</members>
        <name>WaveLens</name>
    </types>
    <types>
        <members>*</members>
        <name>WaveRecipe</name>
    </types>
    <types>
        <members>*</members>
        <name>WaveXmd</name>
    </types>
    <types>
        <members>*</members>
        <name>WaveTemplateBundle</name>
    </types>
    <version>45.0</version>
</Package>

Expected result

All Wave* components from the org should have been retrieved, and the command should exit with code 0 (i.e. without any errors).

Actual result

Some (or all? Not sure how to verify.) wave components get retrieved into force-app/main/default/wave and force-app/main/default/waveTemplates folders, the command exits with code 1 and the below error is reported in the output:

14:50:36.562 sfdx force:source:retrieve --manifest f:\SF\test\manifest\package.xml
ERROR running force:source:retrieve:  Cannot read property 'getWorkspaceElements' of undefined
14:50:50.842 sfdx force:source:retrieve --manifest f:\SF\test\manifest\package.xml ended with exit code 1

VS Code Version:

Version: 1.33.0 (system setup) Commit: 0dd516dd412d42323fc3464531b1c715d51c4c1a Date: 2019-04-04T15:14:28.026Z Electron: 3.1.6 Chrome: 66.0.3359.181 Node.js: 10.2.0 V8: 6.6.346.32 OS: Windows_NT x64 10.0.17763

SFDX CLI Version:

bash-4.3$ sfdx -v
sfdx-cli/7.3.0-94ecf2d5ee win32-x64 node-v10.15.3

OS and version:

Microsoft Windows 10 Pro 10.0.17763

reidaelliott commented 5 years ago

Could you narrow down the package.xml to determine which metadata type is causing the problem. We've done a lot with WaveTemplateBundle. I'm guessing one of the other types is causing this.

smukov commented 5 years ago

Good thinking @reidaelliott. However, it turns out that WaveTemplateBundle is actually causing the issue.

If I comment out WaveTemplateBundle and leave everything else, the retrieve passes without an error. Also, If I comment out everything else and just leave WaveTemplateBundle in the package.xml, I get the same error as originally reported.

The interesting thing is that it still manages to retrieve metadata into the waveTemplates folder, but I'm unsure if retrieval is partial or complete.

Here's the folder structure in VS Code if it's gonna be of any help:

image

reidaelliott commented 5 years ago

I have reproduced the problem as well. Will report back when we have a solution. Thanks

reidaelliott commented 5 years ago

Fix has been put in place and I believe it will roll out this week. thanks for making us aware of this.

tony-tawk-ei commented 5 years ago

Hello , I am having the Same issue but for me it is reproduced for Reports and Dashboards .

ERROR running force:source:retrieve: Cannot read property 'getWorkspaceElements' of undefined 12:25:55.340 sfdx force:source:retrieve --manifest

reidaelliott commented 5 years ago

@tony-tawk-ei the fix that was put in was specific for WaveTemplateBundle and the retrieve command. It sounds like this is happening for a different metadata type? can you confirm it is not WaveTemplateBundle?

tony-tawk-ei commented 5 years ago

I am using package.Xml  generator extension for VScode in order to construct my manifest package. Xml file When I right click on package.Xml to sfdx retrieve I had this error in vscode   When I removed reports and dashboards from package.xml the error disappeared on retrieve action. Sent from my Huawei phone-------- Original Message --------Subject: Re: [forcedotcom/cli] ERROR running force:source:retrieve: Cannot read property 'getWorkspaceElements' of undefined (#78)From: Reid Elliott To: forcedotcom/cli CC: tony-tawk-ei ,Mention @tony-tawk-ei the fix that was put in was specific for WaveTemplateBundle and the retrieve command. It sounds like this is happening for a different metadata type? can you confirm it is not WaveTemplateBundle?

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.

benmcderm commented 5 years ago

@reidaelliott I'm having the same issue with my package.xml:

ERROR running force:source:retrieve: Cannot read property 'getWorkspaceElements' of undefined

I added items back one at a time and found the culprit: <types> <members>*</members> <name>StaticResource</name> </types>

Did something change with StaticResource? I haven't had issues with this package.xml until today.

reidaelliott commented 5 years ago

I ran it using the latest cli installer (sfdx-cli/7.8.1-8f830784cc darwin-x64 node-v10.15.3) against my local server: sfdx force:source:retrieve -x package.xml sfdx force:source:retrieve -m StaticResource Both worked. Maybe you are on a different version or there is something about a static resource in your org causing problems?

kaushr commented 5 years ago

@reidaelliott I get the same error with sfdx-cli/7.22.0-de5c6ecff8 darwin-x64 node-v10.15.3

sfdx force:source:retrieve -x "/Users/kaush/Workspace/EA Templates/EAApp/manifest/package.xml" ERROR running force:source:retrieve: Cannot read property 'getWorkspaceElements' of undefined MacBook-Pro-38:EAApp kaush$ sfdx -v sfdx-cli/7.22.0-de5c6ecff8 darwin-x64 node-v10.15.3

Only happens when I add WaveTemplateBundle to the package.xml

reidaelliott commented 5 years ago

I saw this note : uninstalled SFDX CLI and reinstalled it and retrieve started working. Before I uninstalled it, I had @salesforce/analytics in the plugins along with analytics. After reinstalling I now have just analytics. I suspect @salesforce/analytics was an old plugin maybe? "

Some people have had to uninstall and reinstall sfdx to force update the version. @salesforce/analytics is a separate plugin for commands to use against Einstein analytics projects.

reidaelliott commented 5 years ago

someone else just hit this too and running 'sfdx:plugins update' should get everything working too. We also just released a new version 0.8.0 of @salesforce/analytics with some new features

hagai-shatz commented 5 years ago

I'm getting the same error using sfdx-cli v7.22.0 and analytics plugin v0.8.0

reidaelliott commented 5 years ago

interesting, and this is for a wavetemplatebundle metadata type? This was fixed in the core sfdx-cli has nothing to do with the analytics plugin, but seems like your on the latest versions of both.

hagai-shatz commented 5 years ago

Yes, taking part in analytics workshop today and updated/installed everything. Terminal command and output:

14:43:13.800 sfdx force:source:retrieve -m WaveTemplateBundle:My_Exploration
ERROR running force:source:retrieve:  Cannot read property 'getWorkspaceElements' of undefined
14:43:25.198 sfdx force:source:retrieve -m WaveTemplateBundle:My_Exploration ended with exit code 1
reidaelliott commented 5 years ago

I'd like to get a copy of this metadata to see if I can reproduce. Is it easily available? What if you run with just sfdx force:source:retrieve -m WaveTemplateBundle

hagai-shatz commented 5 years ago

It is on an analytics playground org, I can send you the login in private. Same error when executing sfdx force:source:retrieve -m WaveTemplateBundle

reidaelliott commented 5 years ago

Thanks. are you currently in the class with Skip Sauls?

hagai-shatz commented 5 years ago

Yes, I am.

reidaelliott commented 5 years ago

I think he hit the same problem and somehow was able to get around it, check with him. He can get me the reproducer too if necessary

hagai-shatz commented 5 years ago

Talking to Skip, I get the same message below every time I run sfdx plugins:update

sfdx plugins:update
warning "@salesforce/analytics > @oclif/command@1.5.18" has unmet peer dependency "@oclif/plugin-help@^2".
sfdx-cli: Updating plugins... done
reidaelliott commented 5 years ago

thanks. we'll get that updated should just be a warning. and also reproduced the getWorkspaceElements error so will look into it. It seems the retrieve does work regardless of this error so hopefully not a blocker.

hagai-shatz commented 5 years ago

We use Illuminated Cloud 2 plugin for IntelliJ IDEA, not Visual Code, and the error is failing the process in our case. No rush, we just exploring the options at the moment. Thanks.

reidaelliott commented 5 years ago

fix was made today for sfdx force:source:retrieve of waveTemplateBundles - it should roll out tomorrow

hagai-shatz commented 5 years ago

Working with sfdx-cli 7.23.1

santosvels commented 5 years ago

Not working on sfdx-cli/7.25.3-16d54c01ee win32-x64 node-v10.15.3

11:42:48.313 sfdx force:source:retrieve -m Territory2:RSS_Territory_2020_UAT.AM_A_G_APAC_ANZ_CORE_3 ERROR running force:source:retrieve: Cannot read property 'getWorkspaceElements' of undefined 11:43:00.973 sfdx force:source:retrieve -m Territory2:RSS_Territory_2020_UAT.AM_A_G_APAC_ANZ_CORE_3 ended with exit code 1

Just tried this morning although the metadata seems be retrieved nonetheless

AQTectonic commented 5 years ago

I am also getting the same error while running sfdx force:source:retrieve -x Package.xml

reidaelliott commented 5 years ago

It seems like 'getWorkspaceElements' error message can occur with different metadata types. This thread and what I've fixed is only related to WaveTemplateBundles. That should be fixed. It might be most effective to start a new thread for issues with Territory2 . @AQTectonic I am guessing the members in your package.xml are something besides WaveTemplateBundles?

geraemartinez commented 5 years ago

if you have this in your package.xml it does n't work

<types>
        <members>*</members>
        <name>ApexTestSuite</name>
</types>

but it was working...

clairebianchi commented 5 years ago

The fix was made for WaveTemplateBundles. If you are still experiencing issues please create a new issue

abhinavguptas commented 4 years ago

Getting the same error all of sudden for AuraDefinitionBundle

`

* AuraDefinitionBundle

`

shahwazk58 commented 4 years ago

ERROR running force:source:retrieve: path must not be empty

please help thanks in advance