Skip to content

Retrieving CustomFields causes empty CustomObject to be retrieved #2865

@mdonnalley

Description

@mdonnalley

Summary

(NOTE: created from internal slack thread)

With 2.36.8 or later, I am observing that even though I am trying to retrieve a customField, the CLI fetches the Object-meta.xml file as well and its overwriting the existing Object-meta.xml file by removing all the content of it and making it blank(and even though the file exists the state of the file is always fetched as created for object-meta.xml)

sf project retrieve start -m CustomField:Account_Plan__c.Products_Services__c -o qa

Retrieving v59.0 metadata from sgupta3@salesforce.com.artlr1qa1 using the v60.0 SOAP API
Preparing retrieve request... Succeeded

Retrieved Source
=====================================================================================================================================================
| State   Name                                 Type         Path                                                                                      
| ─────── ──────────────────────────────────── ──────────── ───────────────────────────────────────────────────────────────────────────────────────── 
| Changed Account_Plan__c.Products_Services__c CustomField  force-app/main/default/objects/Account_Plan__c/fields/Products_Services__c.field-meta.xml 
| Created Account_Plan__c                      CustomObject force-app/main/default/objects/Account_Plan__c/Account_Plan__c.object-meta.xml  
git diff force-app/main/default/objects/Account_Plan__c/Account_Plan__c.object-meta.xml
diff --git a/force-app/main/default/objects/Account_Plan__c/Account_Plan__c.object-meta.xml b/force-app/main/default/objects/Account_Plan__c/Account_Plan__c.object-meta.xml
index d175c1808..d254e9b03 100644
--- a/force-app/main/default/objects/Account_Plan__c/Account_Plan__c.object-meta.xml
+++ b/force-app/main/default/objects/Account_Plan__c/Account_Plan__c.object-meta.xml
@@ -1,173 +1,2 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
-    <actionOverrides>
-        <actionName>Accept</actionName>
-        <type>Default</type>
-    </actionOverrides>
-    <actionOverrides>
-        <actionName>Accept</actionName>
-        <formFactor>Large</formFactor>
-        <type>Default</type>
-    </actionOverrides>
-    <actionOverrides>
-        <actionName>Accept</actionName>
-        <formFactor>Small</formFactor>
-        <type>Default</type>
-    </actionOverrides>
-    <actionOverrides>
-        <actionName>CancelEdit</actionName>
-        <type>Default</type>
-    </actionOverrides>
-    <actionOverrides>
-        <actionName>CancelEdit</actionName>
-        <formFactor>Large</formFactor>
-        <type>Default</type>
-    </actionOverrides>
-    <actionOverrides>
-        <actionName>CancelEdit</actionName>
-        <formFactor>Small</formFactor>
-        <type>Default</type>
-    </actionOverrides>
-    <actionOverrides>
-        <actionName>Clone</actionName>
-        <type>Default</type>
-    </actionOverrides>
-    <actionOverrides>

Expected result

Expected force-app/main/default/objects/Account_Plan__c/Account_Plan__c.object-meta.xml to not be empty

Actual result

force-app/main/default/objects/Account_Plan__c/Account_Plan__c.object-meta.xml is empty

System Information

{
  "architecture": "darwin-x64",
  "cliVersion": "@salesforce/cli/2.39.6",
  "nodeVersion": "node-v21.7.1",
  "osVersion": "Darwin 23.4.0",
  "rootPath": "/usr/local/lib/node_modules/@salesforce/cli",
  "shell": "zsh",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.0.16 (core)",
    "@oclif/plugin-commands 3.3.1 (core)",
    "@oclif/plugin-help 6.0.21 (core)",
    "@oclif/plugin-not-found 3.1.6 (core)",
    "@oclif/plugin-plugins 5.0.14 (core)",
    "@oclif/plugin-search 1.0.23 (core)",
    "@oclif/plugin-update 4.2.7 (core)",
    "@oclif/plugin-version 2.0.17 (core)",
    "@oclif/plugin-warn-if-update-available 3.0.15 (core)",
    "@oclif/plugin-which 3.1.8 (core)",
    "@salesforce/cli 2.39.6 (core)",
    "apex 3.1.9 (core)",
    "auth 3.6.3 (core)",
    "custom-metadata 3.1.16 (user)",
    "data 3.3.2 (core)",
    "deploy-retrieve 3.6.6 (core)",
    "info 3.2.3 (core)",
    "limits 3.3.4 (core)",
    "marketplace 1.2.4 (core)",
    "org 4.1.3 (core)",
    "packaging 1.26.4 (user)",
    "schema 3.3.4 (core)",
    "settings 2.2.1 (core)",
    "sobject 1.3.6 (core)",
    "source 3.3.3 (core)",
    "telemetry 3.3.4 (core)",
    "templates 56.2.4 (core)",
    "trust 3.6.6 (core)",
    "user 3.5.2 (core)",
    "@salesforce/sfdx-scanner 3.15.0 (user)",
    "sfdmu 4.30.0 (user)",
    "sfdx-git-delta 5.38.2 (user)",
    "vlocityestools 0.24.5 (user)"
  ]
}

Additional Information

Last working version was 2.35.6

Workaround: retrieve the object at the same time you're retrieving the field, or just retrieve the whole object instead of a single field

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue or pull request that identifies or fixes a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions