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

Error: Could not infer a metadata type when running project retrieve start #2940

Closed
parkerbrown11 opened this issue Jun 24, 2024 · 18 comments
Closed
Labels
investigating We're actively investigating this issue more information required Issue requires more information or a response from the customer stale validated Version information for this issue has been validated

Comments

@parkerbrown11
Copy link

Note
Before you submit your issue, make sure that:

  • You're using the latest version of Salesforce CLI.
  • You've searched both open and closed issues for related posts.
  • You've used the doctor command to diagnose common issues.
  • You understand that GitHub Issues don't adhere to any agreement or SLA.
    • If you require immediate assistance, use official channels such as Salesforce Customer Support.

Summary

When I run the project retrieve start on a new CustomField, the error message in the Actual Result section below occurs. I recently updated sf cli to the latest version. The /decomposed folder in our project contains broken down profile and permission set metadata.

Steps To Reproduce

IMPORTANT
Provide a repository that's configured to reproduce the issue. If you are unable to provide a repo, please explain why not. The more info we have from the start, the faster we can resolve your issue.
We may close your issue if you don't include proper instructions.

  • Generate a project with sf project generate or fork dreamhouse-lwc.
  • Provide detailed step-by-step instructions on how to reproduce the issue.
  1. run this command:
  • sf project retrieve start -m CustomField:pse__Project_Task__c.Product_SKU__c

Expected result

Clean retrieve of the new custom field into project source

Actual result

Error (1): /Users/parkerbrown11/Documents/repos/salesforce/force-app/main/default/permissionsets/decomposed/AD_Credentials_Management/AD_Credentials_Management.xml: Could not infer a metadata type

Try this:

A metadata type lookup for "AD_Credentials_Management.xml" found the following close matches:
-- Did you mean ".xml" instead for the "EmailServicesFunction" metadata type?

Additional suggestions:
Confirm the file name, extension, and directory names are correct. Validate against the registry at:
<https://github.com/forcedotcom/source-deploy-retrieve/blob/main/src/registry/metadataRegistry.json>

If the type is not listed in the registry, check that it has Metadata API support via the Metadata Coverage Report:
<https://developer.salesforce.com/docs/metadata-coverage>

If the type is available via Metadata API but not in the registry

- Open an issue <https://github.com/forcedotcom/cli/issues>
- Add the type via PR. Instructions: <https://github.com/forcedotcom/source-deploy-retrieve/blob/main/contributing/metadata.md>

System Information

using zsh

{
  "architecture": "darwin-arm64",
  "cliVersion": "@salesforce/cli/2.46.6",
  "nodeVersion": "node-v18.12.1",
  "osVersion": "Darwin 23.5.0",
  "rootPath": "/Users/parkerbrown11/.nvm/versions/node/v18.12.1/lib/node_modules/@salesforce/cli",
  "shell": "zsh",
  "pluginVersions": [
    "@jayree/sfdx-plugin-prettier 1.3.66 (user) published 9 days ago (Sat Jun 15 2024) (latest is 1.3.68)",
    "@oclif/plugin-autocomplete 3.1.2 (core)",
    "@oclif/plugin-commands 4.0.2 (core)",
    "@oclif/plugin-help 6.2.1 (core)",
    "@oclif/plugin-not-found 3.2.3 (core)",
    "@oclif/plugin-plugins 5.2.4 (core)",
    "@oclif/plugin-search 1.1.2 (core)",
    "@oclif/plugin-update 4.3.5 (core)",
    "@oclif/plugin-version 2.2.3 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.5 (core)",
    "@oclif/plugin-which 3.2.2 (core)",
    "@rdietrick/sfdx-profile-decompose 1.0.2 (user) published 619 days ago (Fri Oct 14 2022)",
    "@salesforce/cli 2.46.6 (core)",
    "apex 3.1.18 (core)",
    "auth 3.6.21 (core)",
    "data 3.4.6 (core)",
    "deploy-retrieve 3.9.4 (core)",
    "info 3.3.6 (core)",
    "limits 3.3.12 (core)",
    "marketplace 1.2.12 (core)",
    "org 4.2.1 (core)",
    "packaging 2.4.6 (core)",
    "schema 3.3.11 (core)",
    "settings 2.3.1 (core)",
    "sobject 1.4.11 (core)",
    "source 3.4.2 (core)",
    "telemetry 3.4.0 (core)",
    "templates 56.2.11 (core)",
    "trust 3.7.5 (core)",
    "user 3.5.13 (core)",
    "prodlysfcli 1.1.0 (user) published 94 days ago (Fri Mar 22 2024)",
    "sfdx-deliverability-access 1.2.0 (user) published 556 days ago (Fri Dec 16 2022)"
  ]
}

Additional information

@parkerbrown11 parkerbrown11 added the investigating We're actively investigating this issue label Jun 24, 2024
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 Jun 24, 2024
@shetzel
Copy link
Contributor

shetzel commented Jun 24, 2024

How was that decomposed folder created? What are the contents of your sfdx-project.json file?

@parkerbrown11
Copy link
Author

parkerbrown11 commented Jun 25, 2024

Hi @shetzel thanks for the quick reply.

The decomposed folder is created for this custom plugin: @rdietrick/sfdx-profile-decompose 1.0.2
Specifically, when you run this command, the profile and permission set files are split into separate but organized files for easier maintenance. They are held under the decomposed folder.

The full contents of the sfdx-project.json file

  "name": "ghsf",
  "packageDirectories": [
    {
      "path": "force-app",
      "default": true
    }
  ],
  "name": "ghsf",
  "namespace": "",
  "sfdcLoginUrl": "https://login.salesforce.com",
  "sourceApiVersion": "60.0",
  "plugins": {
    "sfdx-plugin-prettier": {
      "enabled": true
    }
  }
}

@shetzel
Copy link
Contributor

shetzel commented Jun 25, 2024

I've never used that plugin, but based on the plugin docs you would need to run the aggregate command before any sf project deploy/retrieve command. That plugin changes the metadata on the local file system in a way that is not understood by the core CLI plugins and will cause problems like you're seeing.

You can continue using that plugin and its commands and dealing with decompose/aggregate and the source tracking issues that can occur, or you can use the new "source behavior" features recently added to the core CLI plugins that handle these things for you. I don't believe Profiles are one of the metadata types supported by the "source behavior" feature though.

Reference these release notes: https://github.com/forcedotcom/cli/blob/main/releasenotes/README.md#2448-jun-5-2024
Reference this discussion: #2544

Please reopen if this does not solve your issue.

@shetzel shetzel closed this as completed Jun 25, 2024
@parkerbrown11
Copy link
Author

Yes, I've been using that plugin for some time now and my retrieves have been working great up until I upgraded to the @salesforce/cli latest from 2.27.6 the other day. Since that upgrade it's been giving the error.

When I go back to @salesforce/cli version 2.27.6 it does a retrieve successfully without having to aggregate first with the decompose plugin. Is there something that changed with the way the retrieve command works between 2.27.6 and the latest?

@shetzel shetzel reopened this Jun 26, 2024
@shetzel
Copy link
Contributor

shetzel commented Jun 26, 2024

Is there something that changed with the way the retrieve command works between 2.27.6 and the latest?

Possibly, but that file structure shouldn't work with any CLI version. Not sure why it wasn't throwing the same error with 2.27.6 but that plugin manipulates metadata in a way that the core CLI plugin (deploy-retrieve) can't work with unless (per the docs) you run that aggregate command.

We can look into it a bit further, but the answer will likely be the same.

@parkerbrown11
Copy link
Author

Yes, when we run a retrieve on our full project, we have to run the aggregate command before it is successful, even with the 2.27.6 CLI version. If I'm retrieving a single CustomField file with the below command, unrelated to any profiles or permission sets, it works with the 2.27.6 version even without running the aggregate command. It doesn't work with the latest version of the sf CLI.

Does that change things at all from your end? Or would the answer still be the same?

sf project retrieve start -m CustomField:pse__Project_Task__c.Product_SKU__c

@WillieRuemmele
Copy link
Member

Hey @parkerbrown11 -

I'm surprised this was working in previous versions given that the file is in the project, have you been able to narrow down it down to what version of the CLI this behavior began in? That would be very useful

have you looked at adding these files to your .forceignore - There's a chance that will cause this directory/file to be skipped now

@parkerbrown11
Copy link
Author

Hi @WillieRuemmele I'll try to narrow things down to the exact version when this behavior began and let you know. I'll also try out adding the files to the .forceignore

@WillieRuemmele WillieRuemmele added the more information required Issue requires more information or a response from the customer label Jul 3, 2024
Copy link

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

@github-actions github-actions bot added the stale label Jul 11, 2024
@parkerbrown11
Copy link
Author

Still planning to perform previous tasks soon.

Copy link

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

@github-actions github-actions bot added the stale label Jul 19, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 26, 2024
@RupertBarrow
Copy link

Maybe a .forceignore file is involved here

@tggagne
Copy link

tggagne commented Nov 6, 2024

Disappointed it's closed. I'm getting the same error.

Note -- I am only trying to retrieve a custom field using the -m parameter.

It seems related to using an older sf client (2.10.2 for me) against a repository that includes an updated metadatatype (genAiPromptTemplates for me) retrieved using a newer version of sf (2.63).

You might ask--how can that be?

Two ways -- a Docker environment with a more current sf and a repo where the change was pushed by another user on another system using a more current version of sf.

Even though the metadata type is part of API 60, which sfdx-project specifies, and even when I add the API version to the sf command line it still fails.

Most interesting--why is sf looking at metadata in the repo I'm not trying to retrieve? Is there a way to tell sf to NOT inspect the local metadata if I didn't ask for it?

@parkerbrown11
Copy link
Author

parkerbrown11 commented Nov 13, 2024

Update:

Adding the 'decomposed' folders to the .forceignore produces the same error. I used sf project list ignored --source-dir force-app/main/default/permissionsets/decomposed/AD_Credentials_Management/AD_Credentials_Management.xml to ensure my .forceignore file was finding and ignoring the decomposed folders.

I haven't had time to narrow the error down to a specific cli version that introduced the error, but am trying to get to it at some point.

I also wonder about the below question from @tggagne:

Most interesting--why is sf looking at metadata in the repo I'm not trying to retrieve? Is there a way to tell sf to NOT inspect the local metadata if I didn't ask for it?

@parkerbrown11
Copy link
Author

parkerbrown11 commented Nov 13, 2024

I can now confirm that the last 'working' version for me is @salesforce/cli/2.39.6. So....

If I am on version 2.39.6 and run sf project retrieve start -m CustomField:Account.Payment_Instrument__c then I receive this:

Image

If I install @salesforce/cli/2.40.7 and run the same command then I receive this:

Image

@cristiand391
Copy link
Member

@parkerbrown11

We fixed that issue on current stable sf v2.66.7:

FIX: When deploying or retrieving metadata, Salesforce CLI no longer attempts to resolve an XML file in the package directory that isn't part of a source component. As a result, you can include XML files in your package directory that aren't related to org metadata, add them to your .forceignore file, and deploys and retrieves will work as expected. (source-deploy-retrieve PR forcedotcom/source-deploy-retrieve#1452)

https://github.com/forcedotcom/cli/tree/main/releasenotes/#2667-november-13-2024-stable

@parkerbrown11
Copy link
Author

parkerbrown11 commented Nov 13, 2024

@cristiand391 Amazing. Ran npm install --global @salesforce/[email protected] to update and it works as expected. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigating We're actively investigating this issue more information required Issue requires more information or a response from the customer stale validated Version information for this issue has been validated
Projects
None yet
Development

No branches or pull requests

6 participants