forcedotcom / salesforcedx-vscode

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

ISV Debugger doesn't work for package which has single quotes or spaces in the package name #3618

Closed bdovh closed 2 weeks ago

bdovh commented 2 years ago

Summary

When following the steps of https://developer.salesforce.com/tools/vscode/en/apex/isv-debugger, I apex my package content to be loaded so that I could set a breakpoint and start a debugging session

Steps To Reproduce:

  1. Create a package
  2. Release a package version
  3. Install package version to subscriber org
  4. As subscriber, grant login access to the package publisher
  5. As package publisher, login to subscriber org
  6. Go to Apex Debugger and click a button to start ISV Debugger Session
  7. Copy the link, go to VS Code and press CMD-Shift-P combination and select "SFDX: Create and Setup Project for ISV Debugging"
  8. Select project destination folder and click Enter

Expected result

The package content will be loaded into the force-app folder so that I could set breakpoint and start a debugging session

Actual result

Error happens. Command 'SFDX: Create and Set Up Project for ISV Debugging' resulted in an error (Running the contributed command: 'sfdx.debug.isv.bootstrap' failed.)

Additional information

Starting SFDX: ISV Debugger Setup, Step 1 of 7: Creating project

11:02:31.564 sfdx force:project:create --projectname Security_Review_2GMP_Demo_Org --outputdir /Users/bdovh/git --template standard target dir = /Users/bdovh/git create Security_Review_2GMP_Demo_Org/config/project-scratch-def.json create Security_Review_2GMP_Demo_Org/README.md create Security_Review_2GMP_Demo_Org/sfdx-project.json create Security_Review_2GMP_Demo_Org/.husky/pre-commit create Security_Review_2GMP_Demo_Org/.vscode/extensions.json create Security_Review_2GMP_Demo_Org/.vscode/launch.json create Security_Review_2GMP_Demo_Org/.vscode/settings.json create Security_Review_2GMP_Demo_Org/force-app/main/default/lwc/.eslintrc.json create Security_Review_2GMP_Demo_Org/force-app/main/default/aura/.eslintrc.json create Security_Review_2GMP_Demo_Org/scripts/soql/account.soql create Security_Review_2GMP_Demo_Org/scripts/apex/hello.apex create Security_Review_2GMP_Demo_Org/.eslintignore create Security_Review_2GMP_Demo_Org/.forceignore create Security_Review_2GMP_Demo_Org/.gitignore create Security_Review_2GMP_Demo_Org/.prettierignore create Security_Review_2GMP_Demo_Org/.prettierrc create Security_Review_2GMP_Demo_Org/jest.config.js create Security_Review_2GMP_Demo_Org/package.json

11:02:33.579 sfdx force:project:create --projectname Security_Review_2GMP_Demo_Org --outputdir /Users/bdovh/git --template standard ended with exit code 0

Starting SFDX: ISV Debugger Setup, Step 2 of 7: Configuring project

11:02:33.581 sfdx force:config:set isvDebuggerSid=00D0Q0000008itB!AQkAQEk6x2dyx6qxcEyuWuSsj.HxeoLGHNUe7jzkfD8YAR1S4jk3fr0QWB9y2a_Xj2b1EhHGo1Gous.9ZXXQ4Nz3p5x.0ix0 isvDebuggerUrl=https://bdsr2gmp--demo.my.salesforce.com instanceUrl=https://bdsr2gmp--demo.my.salesforce.com === Set Config Name Value Success ────────────── ──────────────────────────────────────────────────────────────────────────────────────────────────────────────── ─────── isvDebuggerSid 00D0Q0000008itB!AQkAQEk6x2dyx6qxcEyuWuSsj.HxeoLGHNUe7jzkfD8YAR1S4jk3fr0QWB9y2a_Xj2b1EhHGo1Gous.9ZXXQ4Nz3p5x.0ix0 true isvDebuggerUrl https://bdsr2gmp--demo.my.salesforce.com true instanceUrl https://bdsr2gmp--demo.my.salesforce.com true 11:02:34.445 sfdx force:config:set isvDebuggerSid=00D0Q0000008itB!AQkAQEk6x2dyx6qxcEyuWuSsj.HxeoLGHNUe7jzkfD8YAR1S4jk3fr0QWB9y2a_Xj2b1EhHGo1Gous.9ZXXQ4Nz3p5x.0ix0 isvDebuggerUrl=https://bdsr2gmp--demo.my.salesforce.com instanceUrl=https://bdsr2gmp--demo.my.salesforce.com ended with exit code 0

Starting SFDX: ISV Debugger Setup, Step 2 of 7: Configuring project: Retrieving namespace

11:02:34.447 sfdx force:data:soql:query --query SELECT NamespacePrefix FROM Organization LIMIT 1 --targetusername 00D0Q0000008itB!AQkAQEk6x2dyx6qxcEyuWuSsj.HxeoLGHNUe7jzkfD8YAR1S4jk3fr0QWB9y2a_Xj2b1EhHGo1Gous.9ZXXQ4Nz3p5x.0ix0 --json --loglevel fatal { "status": 0, "result": { "done": true, "totalSize": 1, "records": [ { "attributes": { "type": "Organization", "url": "/services/data/v53.0/sobjects/Organization/00D0Q0000008itBUAQ" }, "NamespacePrefix": null } ] } } 11:02:36.892 sfdx force:data:soql:query --query SELECT NamespacePrefix FROM Organization LIMIT 1 --targetusername 00D0Q0000008itB!AQkAQEk6x2dyx6qxcEyuWuSsj.HxeoLGHNUe7jzkfD8YAR1S4jk3fr0QWB9y2a_Xj2b1EhHGo1Gous.9ZXXQ4Nz3p5x.0ix0 --json --loglevel fatal ended with exit code 0

Starting SFDX: ISV Debugger Setup, Step 3 of 7: Retrieving unpackaged Apex code

11:02:36.898 sfdx force:mdapi:retrieve --retrievetargetdir .sfdx/tools/isvdebuggermdapitmp --unpackaged .sfdx/tools/isvdebuggermdapitmp/package.xml --targetusername 00D0Q0000008itB!AQkAQEk6x2dyx6qxcEyuWuSsj.HxeoLGHNUe7jzkfD8YAR1S4jk3fr0QWB9y2a_Xj2b1EhHGo1Gous.9ZXXQ4Nz3p5x.0ix0 Retrieving source...

=== Status Status: Pending jobid: 09S0Q0000035mtvUAA

=== Result Status: Succeeded jobid: 09S0Q0000035mtvUAA

Wrote retrieve zip to /Users/bdovh/git/Security_Review_2GMP_Demo_Org/.sfdx/tools/isvdebuggermdapitmp/unpackaged.zip. 11:02:46.356 sfdx force:mdapi:retrieve --retrievetargetdir .sfdx/tools/isvdebuggermdapitmp --unpackaged .sfdx/tools/isvdebuggermdapitmp/package.xml --targetusername 00D0Q0000008itB!AQkAQEk6x2dyx6qxcEyuWuSsj.HxeoLGHNUe7jzkfD8YAR1S4jk3fr0QWB9y2a_Xj2b1EhHGo1Gous.9ZXXQ4Nz3p5x.0ix0 ended with exit code 0

Starting SFDX: ISV Debugger Setup, Step 4 of 7: Converting unpackaged Apex code

11:02:46.364 sfdx force:mdapi:convert --rootdir .sfdx/tools/isvdebuggermdapitmp/unpackaged --outputdir force-app No results found 11:02:47.666 sfdx force:mdapi:convert --rootdir .sfdx/tools/isvdebuggermdapitmp/unpackaged --outputdir force-app ended with exit code 0

Starting SFDX: ISV Debugger Setup, Step 5 of 7: Querying for installed packages

11:02:47.668 sfdx force:package:installed:list --targetusername 00D0Q0000008itB!AQkAQEk6x2dyx6qxcEyuWuSsj.HxeoLGHNUe7jzkfD8YAR1S4jk3fr0QWB9y2a_Xj2b1EhHGo1Gous.9ZXXQ4Nz3p5x.0ix0 --json --loglevel fatal { "status": 0, "result": [ { "Id": "0A37Q000000sYHsSAM", "SubscriberPackageId": "03309000000xp05AAA", "SubscriberPackageName": "Bulk Objects' And Fields' Permissions' Manager", "SubscriberPackageNamespace": "bofperman", "SubscriberPackageVersionId": "04t09000000Rwo3AAC", "SubscriberPackageVersionName": "0.0.1", "SubscriberPackageVersionNumber": "0.0.1.20" }, { "Id": "0A30Q0000009UcDSAU", "SubscriberPackageId": "03309000000xp0tAAA", "SubscriberPackageName": "Custom Feature Parameters Application", "SubscriberPackageNamespace": "bofperman", "SubscriberPackageVersionId": "04t09000000RworAAC", "SubscriberPackageVersionName": "0.0.0", "SubscriberPackageVersionNumber": "0.0.0.11" } ] } 11:02:49.606 sfdx force:package:installed:list --targetusername 00D0Q0000008itB!AQkAQEk6x2dyx6qxcEyuWuSsj.HxeoLGHNUe7jzkfD8YAR1S4jk3fr0QWB9y2a_Xj2b1EhHGo1Gous.9ZXXQ4Nz3p5x.0ix0 --json --loglevel fatal ended with exit code 0

Starting SFDX: ISV Debugger Setup, Step 6 of 7: Retrieving packages

11:02:49.608 sfdx force:mdapi:retrieve --retrievetargetdir .sfdx/tools/isvdebuggermdapitmp --packagenames Bulk Objects' And Fields' Permissions' Manager,Custom Feature Parameters Application --targetusername 00D0Q0000008itB!AQkAQEk6x2dyx6qxcEyuWuSsj.HxeoLGHNUe7jzkfD8YAR1S4jk3fr0QWB9y2a_Xj2b1EhHGo1Gous.9ZXXQ4Nz3p5x.0ix0 Retrieving source...

=== Result Status: Failed jobid: 09S0Q0000035muJUAQ

ERROR running force:mdapi:retrieve: The metadata retrieve operation failed: INVALID_CROSS_REFERENCE_KEY: No package named 'Bulk Objects' found 11:02:54.756 sfdx force:mdapi:retrieve --retrievetargetdir .sfdx/tools/isvdebuggermdapitmp --packagenames Bulk Objects' And Fields' Permissions' Manager,Custom Feature Parameters Application --targetusername 00D0Q0000008itB!AQkAQEk6x2dyx6qxcEyuWuSsj.HxeoLGHNUe7jzkfD8YAR1S4jk3fr0QWB9y2a_Xj2b1EhHGo1Gous.9ZXXQ4Nz3p5x.0ix0 ended with exit code 1

Salesforce Extension Version in VS Code: v53.0.1 SFDX CLI Version: sfdx-cli/7.123.0 darwin-x64 node-v14.18.1 OS and version: MacOS BigSur 11.4

randi274 commented 2 years ago

Since we've identified that this is a broader issue than the quotes in the package name, we'll close this one in favor of 3619.

mohanraj-r commented 2 years ago

While dealing with a customer case (W-10891222) and trying to setup "ISV Customer Debugger" errors

Command 'SFDX: Create and Set Up Project for ISV Debugging' resulted in an error (ERROR running force:mdapi:retrieve: The metadata retrieve operation failed: INVALID_CROSS_REFERENCE_KEY: No package named 'Reset Password' found 
Salesforce Extension Version in VS Code:
v54.6.1

SFDX CLI Version:
sfdx-cli/7.144.2 darwin-x64 node-v16.14.2

OS and version:
MacOS BigSur 11.6.5

@WillieRuemmele notes

The bug is how the ISV Debugger is calling the CLI. It seems like it's calling it with an invalid package name ""Reset Password" User Field". I'm not sure how the ISV Debugger generates the list of packages to retrieve, but it seems like there's multiple errors. For instance, the "FinancialForce Consultant Tools" will need to be quoted, or the whole list of packagenames will require quotes around them. Just quickly running a command like that results in a failure

 ➜  sfdx force:mdapi:retrieve --packagenames=FinancialForce Consultant Tools                           
ERROR running force:mdapi:retrieve:  Unexpected arguments: Consultant, Tools

it should be --packagenames="FinancialForce Consultant Tools"

rtoepfer commented 1 year ago

I'm also seeing an error in package naming conventions on Windows machine. Not just in the metadata retrieve but also the extraction -

19:08:00.293 sfdx force:mdapi:retrieve --retrievetargetdir .sfdx\tools\isvdebuggermdapitmp --packagenames VRNA-AS,Files Attachment Notes,Sales Goals 1.4,Department Goals 1.1,DomoReporting,Veruna Fast Tracks,SalesforceIQ Inbox,SalesWings Studio,Launch Flow Modal,Salesforce Connected Apps,Salesforce Mobile Apps,Zero Dollar Commission Flow,GL Coverage Widget,VerunaCore,Podium Conversation Sync,Skunkworks Extended Functions,Skunkworks Policy Payment,vrnaasUnmanaged,NeonVRNAASbridge,Veruna Download Central,Salesforce.com CRM Dashboards,Commissions Auto Renew,MarketingCloudConnectedApp,CMTD Enhanced Related List,Veruna Integrations,Ask Kodiak for Salesforce,B ATOMIC | THE DATA KRAKEN,SDocs,Accounting Seed Financial Suite,Marketing Cloud,Formstack,Formstack Documents (WebMerge) --targetusername 00D6w0000004brg!ARcAQPa1fV7P4urOmXGaK9cBtoDpzW3fTh4lRgPujI1U7zdT_evGz2mwml_mnr73g3gxwMJht4t786SAOIVTGyyfX7mlCS9f ended with exit code 0

Error extracting packages: Error: EINVAL: invalid argument, mkdir 'c:\Sandbox\Test_Alliance_Insurance_Services.sfdx\tools\isvdebuggermdapitmp\packages\B ATOMIC | THE DATA KRAKEN'

daphne-sfdc commented 2 weeks ago

I tested this in April 2024. I was able to create 2GP managed packages with spaces and single quotes in their names. I was also able to install them into subscriber sandboxes and run the ISV debugger on Salesforce projects created using those packages.

This is no longer a bug, as it cannot be reproduced.