forcedotcom / salesforcedx-vscode

Salesforce Extensions for VS Code
https://developer.salesforce.com/tools/vscode
BSD 3-Clause "New" or "Revised" License
953 stars 405 forks source link

SVCode SFDX: Diff File Against Org Broken #4544

Closed KevinGossentCap closed 2 months ago

KevinGossentCap commented 2 years ago

Summary

I don't know since when, but with actual VSCode version, actual extensions and sfdx-cli latest or latest-rc this feature is broken. It invokes but nothing happens, nothing is shown.

Steps To Reproduce:

Expected result

Diff between ORG and local to be shown as it did previously.

Actual result

Output tells

Additional information

Feel free to attach a screenshot.

Salesforce Extension Version in VS Code: 56.5.1

SFDX CLI Version: 7.177.0

OS and version: Windows 10

randi274 commented 2 years ago

Hi @KevinGossentCap - are you seeing this with any specific metadata, or with everything?

KevinGossentCap commented 2 years ago

Hi @randi274 I'd have to test for more metadata types, but definitely happening with layouts.

gbockus-sf commented 2 years ago

Just another piece of info for this issue. I tested this functionality yesterday as part of QE'ing PR https://github.com/forcedotcom/salesforcedx-vscode/pull/4543 and it was working as expected. I was testing on a mac with sfdx-cli/7.175.0. I'll check it for the latest release and see if I can repo the issue.

gbockus-sf commented 2 years ago

@KevinGossentCap Tested with the previous release and I can't repo the issue (tested using an LWC component file and a layout file).

One note. Here we aren't using any cli functionality so it the installed version of the sfdx should have zero impact for this particular issue.

There may be an error occurring. To see any errors that we aren't handling you can toggle the Developer console via the command pallet: 'Developer: Toggle Developer Tools'. That will open the dev tools where you can view the console for any errors being thrown. Please copy any that show up after running a diff and share them here.

A couple of things to sanity check:

  1. Where you are you right clicking to select the 'Diff File against Org'?

  2. If you attempt to diff something that isn't a SF file does it show the error dialog? (I ran the diff by right clicking the sfdx-config.json file and selecting the diff from the context menu. Screen Shot 2022-11-11 at 3 38 31 PM

  3. If you select a folder does it behave any differently? Screen Shot 2022-11-11 at 3 34 11 PM

I took a quick pass at the source for this command and didn't see any obvious places where it would swallow errors.

randi274 commented 2 years ago

Also gave a page layout a test on my Windows box with the latest extensions (v56.5.1), and I'm able to see a clean diff when there's no changes, and highlights when I make changes both locally and in the org. Hopefully @gbockus-sf's thoughts give us some better insight into what might be happening for you 🤞

Clean diff: image

Diff with changes (local and in the org): image

KevinGossentCap commented 2 years ago

Hi, I've just tested more. It's really strange

gbockus-sf commented 2 years ago

Thanks for the update @KevinGossentCap.
Can you toggle the developer tools: Developer: Toggle Developer Tools and see if any errors are thrown when you attempt to run the diff?

I ran a trace back a few days through our analytics and didn't find any diff calls that resulted in an error so I won't be too surprised if nothing shows up.

Another thing we could check is if the request to get the file is making it to the org. You can verify this by first navigating to your Org -> Setup -> Company Information. On that page there is an entry under Company Information -> API Requests, Last 24 Hours. Note the current value then run the diff command in vscode. After it completes refresh the company information page and see if the Api requests value increases. It's not a perfect test in that there could be a lot of things making API requests, but if you're working on a org without lots of activity you can see the API request value increase by 1.

KevinGossentCap commented 2 years ago

Hi @gbockus-sf , I've just tested both and

gbockus-sf commented 2 years ago

@KevinGossentCap Thanks for the update.

Ok so the only route I could think of to track this down is to add a bunch of debug logging to see where in the flow the diff is failing. I added this logging and generated a vsix file that I attached to a release on my fork of this repo. https://github.com/gbockus-sf/salesforcedx-vscode/releases/tag/v56.5.1-test Screen Shot 2022-11-22 at 5 42 43 PM

I included instructions for how to install and see the debug logging on the release notes. Please give it a try when you get a chance and provide back the debug logging output.

Thanks for your patience on this!

KevinGossentCap commented 2 years ago

Here is the log vscode-app-1669203078106.log

github-actions[bot] commented 2 years ago

This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted.

KevinGossentCap commented 2 years ago

dummy message just to maintain it open

gbockus-sf commented 2 years ago

Thanks for the bump and the log. I'm taking a look now.

git2gus[bot] commented 2 years ago

This issue has been linked to a new work item: W-12151316

AprilShenk commented 2 years ago

I'm having a similar issue except with Deploy Source to Org. It seems to happen after the second or third Deployment. I followed the steps here and don't see anything in my console either. After pushing once or twice the third will never complete. Cancelling the deploy and deploying again sometimes works along with reloading the window. The only thing that is consistent is if I completely close VS code and open it again.

I have the most up to date version of sfdx, vs code, and the extension pack.

gbockus-sf commented 2 years ago

@KevinGossentCap I tracked down the issue. The root of the problem is your local layout file doesn't look like it was retrieved from the org using the cli or vscode. The file name is Opportunity-Opportunity Layout.layout. When it gets pulled via the cli or vscode it will include -meta.xml at the end of the file name.

To verify this can you try the following:

  1. rename a layout file adding the -meta.xml to the end of the file name. (or just do a retrieve of the layout via the Org Browser )
  2. Verify the diff command shows the diff viewer.

Adding the extension is a function of the tooling SF source-deploy-retrieve node library used by vscode and the cli. If you pull the source through one of those tools it should be correctly named to work with the SF vscode extensions.

Screen Shot 2022-12-01 at 4 09 31 PM
gbockus-sf commented 2 years ago

I'm having a similar issue except with Deploy Source to Org. It seems to happen after the second or third Deployment. I followed the steps here and don't see anything in my console either. After pushing once or twice the third will never complete. Cancelling the deploy and deploying again sometimes works along with reloading the window. The only thing that is consistent is if I completely close VS code and open it again.

I have the most up to date version of sfdx, vs code, and the extension pack.

Hi @AprilShenk Would you mind opening a new issue for the deploy issues you are experiencing. I think it's a related but separate path from this diff issue.

Thanks

KevinGossentCap commented 2 years ago

@gbockus-sf , I start to see a pattern. My components ARE taken using the CLI. But they are taken through mdapi. It seems the diff won't work for components that have the slightest difference (even if only the file extension) between source api and mdapi. A pity as numerous metadata types only have an extension difference between both source formats (layout being one of them)

gbockus-sf commented 1 year ago

@KevinGossentCap Definitely feel like we are making progress.

Would you mind providing the cli command you are using to retrieve the components?

If we can clarify the use case this seems like something that should be enhanced when diffing through the VSCode extensions. The condition we are checking to find the files for diffing can be updated easily enough, I just need to verify that there won't be some surprised corner cases I don't expect.

Thanks!

KevinGossentCap commented 1 year ago

Hi @gbockus-sf , simple CLI command : sfdx force:mdapi:retrieve Most parameters are the same as the sfdx force:source:retrieve, main difference is that you have to build a package.xml file (where with source you can specify the targeted metadata by other means)

But, as I wrote, there are some metadata that are identical between mdapi and source (only a file extension change) where others are really different. You'd have to know for which ones you can propose the diff and for which you'd give an intelligent error message like "it's not possible to compare this mdapi object with its source format counterpart as they are built differently"

mshanemc commented 1 year ago

FYI: sfdx force:source:manifest:create will let you get a manifest using the same -m, -p, that the other source commands recognize.

diyer commented 2 months ago

Closing this old issue. Please create a new one if the problem persists with our lates VS Code Extensions. Thank you!