Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve components by a pattern does not work: sf project retrieve start -m 'ApexClass:MyApex*' #2522

Closed
itaishmida opened this issue Oct 11, 2023 · 8 comments
Labels
bug Issue or pull request that identifies or fixes a bug validated Version information for this issue has been validated

Comments

@itaishmida
Copy link

Summary

Trying to use a new feature - retrieve components by a pattern
According to the docs - in current SF version and previous one, I can use * to get components by a pattern
https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_project_commands_unified.htm#cli_reference_project_retrieve_start_unified
When I run a command like this, it does not get any component
`sf project retrieve start --metadata 'ApexClass:MyApex*'

Steps To Reproduce

according to the docs, if I run this command:
sf project retrieve start --metadata 'ApexClass:MyApex*'
it should get all apex classes with MyApex in their names
this does not work at all, I checked also
sf project retrieve start --metadata 'ApexClass:a*'
And I have many classes starting with a

Expected result

should retrieve all components with the pattern

Actual result

when I run the command, this is the result I get:

Preparing retrieve request... done
Nothing retrieved

System Information

I use powershell on windows

{
  "cliVersion": "@salesforce/cli/2.11.8",
  "architecture": "win32-x64",
  "nodeVersion": "node-v16.14.2",
  "osVersion": "Windows_NT 10.0.19045",
  "shell": "cmd.exe",
  "rootPath": "C:\\Users\\myuser\\AppData\\Roaming\\npm\\node_modules\\@salesforce\\cli",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 2.3.8 (core)",
    "@oclif/plugin-commands 2.2.26 (core)",
    "@oclif/plugin-help 5.2.19 (core)",
    "@oclif/plugin-not-found 2.4.1 (core)",
    "@oclif/plugin-plugins 3.8.2 (core)",
    "@oclif/plugin-search 0.0.22 (core)",
    "@oclif/plugin-update 3.2.3 (core)",
    "@oclif/plugin-version 1.3.10 (core)",
    "@oclif/plugin-warn-if-update-available 2.1.0 (core)",
    "@oclif/plugin-which 2.2.32 (core)",
    "@salesforce/cli 2.11.8 (core)",
    "apex 2.3.15 (core)",
    "auth 2.8.17 (core)",
    "data 2.5.12 (core)",
    "deploy-retrieve 1.18.3 (core)",
    "info 2.6.45 (core)",
    "limits 2.3.35 (core)",
    "login 1.2.31 (core)",
    "marketplace 0.2.2 (core)",
    "org 2.10.8 (core)",
    "packaging 1.20.1 (link) C:\\Users\\myuser\\AppData\\Roaming\\npm\\node_modules\\@salesforce\\plugin-packaging",
    "schema 2.3.28 (core)",
    "settings 1.4.30 (core)",
    "sobject 0.2.7 (core)",
    "source 2.10.36 (core)",
    "telemetry 2.3.4 (core)",
    "templates 55.5.13 (core)",
    "trust 2.6.15 (core)",
    "user 2.3.32 (core)",
    "salesforce-app 1.0.0 (link) C:\\Users\\myuser\\Desktop\\dev\\repos\\salesforce"
  ]
}
@itaishmida itaishmida added the investigating We're actively investigating this issue label Oct 11, 2023
@github-actions
Copy link

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.

@github-actions github-actions bot added the validated Version information for this issue has been validated label Oct 11, 2023
@iowillhoit
Copy link
Contributor

Hey @itaishmida, thanks for the Issue. I am not seeing this on my local machine. I am able to retrieve and deploy using an *. I even rolled back to your exact version of sf.

> sf project retrieve start --metadata 'ApexClass:Fil*'
Retrieving v58.0 metadata from [email protected] using the v58.0 SOAP API
Preparing retrieve request... Succeeded

Retrieved Source
===================================================================================================
| State   Name              Type      Path
| ─────── ───────────────── ───────── ─────────────────────────────────────────────────────────────
| Changed FileUtilities     ApexClass force-app/main/default/classes/FileUtilities.cls
| Changed FileUtilities     ApexClass force-app/main/default/classes/FileUtilities.cls-meta.xml
| Changed FileUtilitiesTest ApexClass force-app/main/default/classes/FileUtilitiesTest.cls
| Changed FileUtilitiesTest ApexClass force-app/main/default/classes/FileUtilitiesTest.cls-meta.xml

A few things:

  • Can you try to replicate this with the Dreamhouse sample org?
  • It looks like you already are, but confirm you are wrapping your flag value in single quotes 'ApexClass:Foo*'
  • Are you seeing the same result if you use Command Prompt instead of Powershell?

@iowillhoit iowillhoit added more information required Issue requires more information or a response from the customer and removed investigating We're actively investigating this issue labels Oct 11, 2023
@shetzel
Copy link
Contributor

shetzel commented Oct 11, 2023

One last thing to check is that you're targeting an org that has those apex classes. The command you showed: sf project retrieve start --metadata 'ApexClass:MyApex*' uses a default org so be sure to verify it's the org you expect.

@itaishmida
Copy link
Author

Thank you for the quick reply
I created a new trailhead playground org and created a test class named ApexTest
Now I connected my VS code to this org and run it from powershell and from command prompt, the results are different, but both cannot get the component, and it seams like command prompt does not support single quote so I put double quotes:
(look that when I specify the specific component - it gets it)
powershell:
image

Command Line:
image

the default org is ok and set up, and you can see that when I specify the specific class the retrieve works good

Another thing to add - my class folder is empty, when it has files, the behavior is different ( I did not understand what is the behavior)

@iowillhoit
Copy link
Contributor

Aha! That's whats going on. If the class does not exist locally, it will not find any matches.

Image

@iowillhoit iowillhoit added bug Issue or pull request that identifies or fixes a bug and removed more information required Issue requires more information or a response from the customer labels Oct 12, 2023
@git2gus
Copy link

git2gus bot commented Oct 12, 2023

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

@iowillhoit
Copy link
Contributor

Huh, there are a few other oddities with the wildcard matching.

Single character retrieves all(?) Classes

> sf project retrieve start --metadata 'ApexClass:P*'
Retrieving v58.0 metadata from [email protected] using the v58.0 SOAP API
Preparing retrieve request... Succeeded

Retrieved Source
=================================================================================================================
| State   Name                     Type      Path
| ─────── ──────────────────────── ───────── ────────────────────────────────────────────────────────────────────
| Changed FileUtilities            ApexClass force-app/main/default/classes/FileUtilities.cls
| Changed FileUtilities            ApexClass force-app/main/default/classes/FileUtilities.cls-meta.xml
| Changed GeocodingService         ApexClass force-app/main/default/classes/GeocodingService.cls
| Changed GeocodingService         ApexClass force-app/main/default/classes/GeocodingService.cls-meta.xml
| Changed GeocodingServiceTest     ApexClass force-app/main/default/classes/GeocodingServiceTest.cls
| Changed GeocodingServiceTest     ApexClass force-app/main/default/classes/GeocodingServiceTest.cls-meta.xml
| Changed PagedResult              ApexClass force-app/main/default/classes/PagedResult.cls
| Changed PagedResult              ApexClass force-app/main/default/classes/PagedResult.cls-meta.xml
| Changed PropertyController       ApexClass force-app/main/default/classes/PropertyController.cls
| Changed PropertyController       ApexClass force-app/main/default/classes/PropertyController.cls-meta.xml
| Changed SampleDataController     ApexClass force-app/main/default/classes/SampleDataController.cls
| Changed SampleDataController     ApexClass force-app/main/default/classes/SampleDataController.cls-meta.xml
| Changed TestPropertyController   ApexClass force-app/main/default/classes/TestPropertyController.cls
| Changed TestPropertyController   ApexClass force-app/main/default/classes/TestPropertyController.cls-meta.xml
| Changed TestSampleDataController ApexClass force-app/main/default/classes/TestSampleDataController.cls
| Changed TestSampleDataController ApexClass force-app/main/default/classes/TestSampleDataController.cls-meta.xml

Two characters is more narrow, but still retrieves Classes I would not expect

> sf project retrieve start --metadata 'ApexClass:Pa*'
Retrieving v58.0 metadata from [email protected] using the v58.0 SOAP API
Preparing retrieve request... Succeeded

Retrieved Source
=============================================================================================================
| State   Name                   Type      Path
| ─────── ────────────────────── ───────── ──────────────────────────────────────────────────────────────────
| Changed PagedResult            ApexClass force-app/main/default/classes/PagedResult.cls
| Changed PagedResult            ApexClass force-app/main/default/classes/PagedResult.cls-meta.xml
| Changed PropertyController     ApexClass force-app/main/default/classes/PropertyController.cls
| Changed PropertyController     ApexClass force-app/main/default/classes/PropertyController.cls-meta.xml
| Changed TestPropertyController ApexClass force-app/main/default/classes/TestPropertyController.cls
| Changed TestPropertyController ApexClass force-app/main/default/classes/TestPropertyController.cls-meta.xml

Three characters gets what you'd expect

> sf project retrieve start --metadata 'ApexClass:Pag*'
Retrieving v58.0 metadata from [email protected] using the v58.0 SOAP API
Preparing retrieve request... Succeeded

Retrieved Source
=======================================================================================
| State   Name        Type      Path
| ─────── ─────────── ───────── ───────────────────────────────────────────────────────
| Changed PagedResult ApexClass force-app/main/default/classes/PagedResult.cls
| Changed PagedResult ApexClass force-app/main/default/classes/PagedResult.cls-meta.xml

@jshackell-sfdc
Copy link
Collaborator

This issue is addressed in 2.21.7 (Dec 13, 2023). Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue or pull request that identifies or fixes a bug validated Version information for this issue has been validated
Projects
None yet
Development

No branches or pull requests

4 participants