forcedotcom / salesforcedx-vscode

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

Cannot deploy namespaced Apex classes in unlocked packages to org #5637

Open Banuson opened 3 weeks ago

Banuson commented 3 weeks ago

Hello,

I want to update a class from an unlocked packaged installed in my org with namespace MyPackage.

I am able to retrieve it, but if I want to change anything (adding a comment for example) in that file I am not able to deploy. I want to deploy using metadata API. The apex class file is : classes/MyPackage__myClass.cls with MyPackage namespace. public class myClass { // class content } But when I try to deploy I have this error message: File name mismatch with class name: myClass

Another issue is that in Org Browser: files shows with doubled namespace for example: MyPackageMyPackagemyClass.cls Retrieve using the org browser throws this error: Entity of type 'ApexClass' named 'MyPackageMyPackagemyClass' cannot be found

Currently I can only edit the class from Dev Console or Setup>Apex Class.

Salesforce Extension Version in VS Code: v60.15.0 Salesforce CLI Version: @salesforce/cli/2.42.6 win32-x64 node-v20.12.2 OS and version: Microsoft Windows 11 Enterprise 10.0.22621 Build 22621 VS Code version: Version: 1.90.0 Most recent version of the extensions where this was working: N/A

svc-idee-bot commented 3 weeks ago

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

daphne-sfdc commented 3 weeks ago

Hi @Banuson, We're aware of the issue with the duplicate namespaces in the org browser, as it was previously filed here: https://github.com/forcedotcom/salesforcedx-vscode/issues/5598. There is a workaround to retrieve using the manifest instead.

Let me try to replicate your issue with editing and deploying the namespaced Apex class in the unlocked package. I'll let you know if I can replicate it.

Banuson commented 3 weeks ago

Hi @daphne-sfdc,

Just checking in to see if you had a chance to look into the issue with editing and deploying the namespaced Apex Class in the unlocked package. Thanks for your help!

daphne-sfdc commented 3 weeks ago

Hi @Banuson, Sorry for the delay. My team was working to resolve an urgent issue yesterday so I haven't gotten the chance to check this yet. I'll get back to you with my findings later today.

daphne-sfdc commented 2 weeks ago

@Banuson Looks like you're correct that this is a bug - I was able to reproduce this issue using a new unlocked package that I created and installed into an empty scratch org. What's particularly interesting is that I'm unable to deploy namespaced Apex classes using the CLI either - we'll investigate our shared libraries to see what's going on.

daphne.yang@daphney-ltmkef9 classes % sf project deploy start --source-dir GlobalClass0000.cls
Error (1): GlobalClass0000.cls: File or folder not found

daphne.yang@daphney-ltmkef9 classes % sf project deploy start --source-dir svcideebot__GlobalClass0000.cls
Error (1): force-app: File or folder not found

Thanks for filing this issue, and sorry for the inconvenience.

git2gus[bot] commented 2 weeks ago

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

Banuson commented 2 weeks ago

@daphne-sfdc Thanks for confirming the issue and looking into it. Could you please provide an estimated timeline for a fix?

daphne-sfdc commented 2 weeks ago

Hi @Banuson, Our team is continuing to investigate what is going on with the namespaced deployments. We'll keep you in the loop with any updates that we have. Thank you for your patience.

Banuson commented 6 days ago

Hello @daphne-sfdc,

Are there any updates regarding this issue?

Thank you!

daphne-sfdc commented 2 days ago

Hi @Banuson, Our team is still actively investigating this issue. We'll update you when we find anything important regarding this use case. Thank you.