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 "Unexpected child metadata" with "force:source:retrieve" command when I try to retrieve any component #1241

Closed
JavierCarvajalLBS opened this issue Oct 18, 2021 · 31 comments

Comments

@JavierCarvajalLBS
Copy link

JavierCarvajalLBS commented Oct 18, 2021

Recently, when I try to execute a force:source:retrieve command in VS Code to get any component from the SFDC connected org, I receive the error message:

Unexpected child metadata [\Activity-bg\Activity_Group__c.fieldTranslation-meta.xml] found for parent type [CustomObjectTranslation]

image
image

It is received using a package.xml, or specifying the specific component to be retrieved, and even when neither object Activity, nor Activity Group field nor any object translation is involved in the retrieve command.
If I delete that CustomObjectTranslation from local, the same error message is received but from a different field from the Activity object. If I delete the Activity object from local, I receive the same error message, but from a different object.

I guess it is some kind of error related to the project structure local, but I can´t find the reason because the error message is not helping.

@JavierCarvajalLBS JavierCarvajalLBS added the investigating We're actively investigating this issue label Oct 18, 2021
@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.

@cristiand391
Copy link
Member

This seems like a duplicate of #1241

Regarding other errors when you delete the Activity object, did you start to see these recently after an update or are you still reorganizing your project structure?

@JavierCarvajalLBS
Copy link
Author

It is not a duplicate, actually it is #1241

I don´t want to delete the Activity object. I have all my SF org in the repository and all was working fine (in fact I could execute the retrieve for all the components without any problem), but suddenly I received that error message when I tried to retrieve again some components that were been updated in the SF UI.

I just can use the source:force:retrieve command with the --sourcepath but I need to have the component already in my project to use it and I can´t retrieve more than one component at a time. If I try to use with --manifest to use a package.xml or with -m to retrieve just one component, I receive the Unexpected child metadata error message.

@JavierCarvajalLBS
Copy link
Author

I´m still investigating this issue and I can see that in my force-app\main\default\objectTranslations folder I have objectTranslation-meta.xml files and fieldTranslation-meta.xml files.

  • objectTranslation XML files contain a CustomObjectTranslation element with different elements inside the object (fieldsets, recordtypes, validationrules,...)
  • fieldTranslation XML files instead contain a CustomFieldTranslation element with the different elements inside the field (label, name, picklistvalues,...)

It is normal? Because the error message is saying that it has found an unexpected child metadata fieldTranslation XML for parent type CustomObjectTranslation, and maybe it is because the objectTranslations folder just can have objectTranslation XML files.
My concern is because that folder structure was created retrieving the metadata from the SF org using a package.xml file generated with the SF package.xml generator tool.

@JavierCarvajalLBS
Copy link
Author

JavierCarvajalLBS commented Oct 19, 2021

I think I´ve found the reason for this problem.

The main cause is because in some objectTranslation folders there isn´t an objectTranslation XML file.
If I add an objectTranslation XML file in the folder which is raising the error, that error disappears.
My main concern is why some objectTranslation folders contain an objectTranslation XML file but other folders do not.

I use the Salesforce Package.xml Generator plugin in VSC and I know that I have to include in the package.xml the objects that I want to retrieve the translation from, and I included all the objects, and fields in the same package.xml which contains the objectranslations so I don´t know why some objects have the objectTranslation file but other objects do not.

@cristiand391
Copy link
Member

Sorry, I pasted the wrong link, dup: #1233.

This started to happen after this PR: forcedotcom/source-deploy-retrieve#461

If I add an objectTranslation XML file in the folder which is raising the error, that error disappears.

Yes, as other user has commented in the issue above, that's the current workaround 👍🏼

@JavierCarvajalLBS
Copy link
Author

Does nobody know how to avoid this problem?
Because if I´ve tried to retrieve all the translations from my SF org, and the objectTranslation files are still missing.

@IVerkhosh
Copy link

Have the same issue, after updating to version 7.120 and 7.123

@WillieRuemmele
Copy link
Member

WillieRuemmele commented Oct 28, 2021

Hi @IVerkhosh @JavierCarvajalLBS thanks for the patience. This issue has been addressed here and will be released the latest-rc v7.125.0 release of the CLI later today

@MorganMarchese
Copy link

This is still not fixed, 11/10/2021. Still happening when retrieving or pushing metadata using a package.xml file.

@shetzel
Copy link
Contributor

shetzel commented Nov 10, 2021

@MorganMarchese - what is the output of sfdx version --verbose? Do you have a repo (with sample package.xml) we can use to reproduce this issue? What is the stack trace when you append --dev-debug when running the command?

@firatesmer
Copy link

I have the same issue. I have a folder in my project called objects and raising the error and when I change the name of the folder, the error goes away.

sfdx-cli/7.126.0 win32-x64 node-v16.13.0
Error message: Unexpected child metadata [\force-app\main\default\classes\enums\objects\cardPaymentMethod\CardPaymentMethodCategory.cls-meta.xml] found for parent type [CustomObject]

@emrealtan-osf
Copy link

Same here for sfdx-cli/7.124.0 win32-x64 node-v14.18.1

@karlamartinezh
Copy link

karlamartinezh commented Nov 15, 2021

Hello!! same error with the version sfdx-cli/7.127.0 win32-x86 node-v16.13.0 , any solution?

In my case this was the error "Unexpected child metadata [\force-app\main\default\objectTranslations\Activity-pt_PT\Accepted_Information__c.fieldTranslation-meta.xml] found for parent type [CustomObjectTranslation]"

@mgrygielSii
Copy link

Sorry, I pasted the wrong link, dup: #1233.

This started to happen after this PR: forcedotcom/source-deploy-retrieve#461

If I add an objectTranslation XML file in the folder which is raising the error, that error disappears.

Yes, as other user has commented in the issue above, that's the current workaround 👍🏼

WORKAROUND: As stated above, just create a OBJECT_NAME.objectTranslation-meta.xml in the folder that is causing problem.

Example:
Starting SFDX: Retrieve Source from Org
Unexpected child metadata [\force-app\main\default\objectTranslations\Opportunity-en_US\amount_opportunity.fieldTranslation-meta.xml] found for parent type [CustomObjectTranslation]

The current folder structure:
/objectTranslations
--/Opportunity-en_US
----/amount_opportunity.fieldTranslation-meta.xml

A desired folder structure:
/objectTranslations
--/Opportunity-en_US
----/amount_opportunity.fieldTranslation-meta.xml
----/Opportunity-en_US.objectTranslation-meta.xml <- create this file with basic XML

After creating the main obj Translation file, SFDX behaves as expected.

Hope somebody will benefit from this.
Thx, Marek.

@hhssuuyyaa
Copy link

I have the same issue. I have a folder in my project called objects and raising the error and when I change the name of the folder, the error goes away.

sfdx-cli/7.126.0 win32-x64 node-v16.13.0 Error message: Unexpected child metadata [\force-app\main\default\classes\enums\objects\cardPaymentMethod\CardPaymentMethodCategory.cls-meta.xml] found for parent type [CustomObject]

This worked for me too. Weird issue, hope this gets fixed in latest cli.

@shetzel
Copy link
Contributor

shetzel commented Nov 22, 2021

Seems there are multiple issues being reported here.

  1. Unexpected child metadata for CustomObject. This will happen when you have metadata that is not part of a CustomObject within a directory containing "objects" in the path. In the examples reported above there are apex classes inside an objects directory. The way the SDR library's metadata file parsing currently works, when trying to categorize the metadata file into a type it will first check if the path matches a well known directory name such as "objects" and if it does, it uses it to determine the type classification. To fix this problem you can remove the "objects" directory from the path. There is an item in the backlog to change the type detection logic to first look at the file suffix to determine the type and that would fix this issue. That fix will come within a few weeks.
  2. Unexpected child metadata for CustomObjectTranslation. This shouldn't happen anymore with recent (7.125.0 and later) CLI plugins. If it does, we're looking for a repro. A CustomFieldTranslation should never exist without a CustomObjectTranslation. If it does, then however that retrieve happened is where the bug is. I've seen in the posts above that this might be happening from VS Code so maybe it's a bug for that action but not the CLI. If someone has a way to reproduce this only in the CLI please post here. Without a repro, nothing is being done to fix this.

@shetzel shetzel added more information required Issue requires more information or a response from the customer and removed investigating We're actively investigating this issue labels Nov 22, 2021
@JavierCarvajalLBS
Copy link
Author

JavierCarvajalLBS commented Nov 29, 2021

@shetzel I´m still having the same issue today:

Metadata API request failed: Component conversion failed: Unexpected child metadata [\force-app\main\default\objectTranslations\efl__EFL_Child_Objects_List__c-en_US\efl__Object_Name__c.fieldTranslation-meta.xml] found for parent type [CustomObjectTranslation]

I´m using a package.xml with all the CustomObject included and using the wildcard * in the CustomObjectTranslation component (I need to retrieve all the components in the org).

After investigation, this issue is just with one managed-package component (component efl__EFL_Child_Objects_List__c from the managed package Enhanced Files List). If I remove the component of the list of CustomObject elements in the package.xml, no issue is raised. If the object is in the list, a CustomObjectTranslation file is created during the retrieve and the error raises. The main problem is that I can´t remove the object name because we have to retrieve all the custom objects in the org using the wildcard (*) and, in that case, the error always raises

And it is my system configuration:
{
"cliVersion": "sfdx-cli/7.127.0",
"architecture": "win32-x64",
"nodeVersion": "node-v16.13.0",
"pluginVersions": [
"@oclif/plugin-autocomplete 0.3.0 (core)",
"@oclif/plugin-commands 1.3.0 (core)",
"@oclif/plugin-help 3.2.3 (core)",
"@oclif/plugin-not-found 1.2.4 (core)",
"@oclif/plugin-plugins 1.10.1 (core)",
"@oclif/plugin-update 1.5.0 (core)",
"@oclif/plugin-warn-if-update-available 1.7.0 (core)",
"@oclif/plugin-which 1.0.3 (core)",
"@salesforce/sfdx-plugin-lwc-test 0.1.7 (core)",
"alias 1.1.22 (core)",
"apex 0.3.0 (core)",
"auth 1.7.5 (core)",
"config 1.2.47 (core)",
"custom-metadata 1.0.12 (core)",
"data 0.6.4 (core)",
"generator 1.2.1 (core)",
"limits 1.2.3 (core)",
"org 1.9.0 (core)",
"salesforce-alm 53.4.2 (core)",
"schema 1.0.10 (core)",
"sfdx-cli 7.127.0 (core)",
"source 1.4.0 (core)",
"telemetry 1.2.8 (core)",
"templates 52.6.0 (core)",
"trust 1.0.10 (core)",
"user 1.5.2 (core)"
],
"osVersion": "Windows_NT 10.0.18362"
}

@no-response no-response bot removed the more information required Issue requires more information or a response from the customer label Nov 29, 2021
@JavierCarvajalLBS
Copy link
Author

More investigation on the issue:

  1. If I generate a package.xml with just the CustomObject efl__EFL_Child_Objects_List__c inside, the retrieve command works fine and retrieves the CustomObject metadata file and a CustomField metadata file.
  2. If I generate a package.xml with just the CustomObjectTranslation efl__EFL_Child_Objects_List__c-en_US inside, the retrieve command works fine but it doesn´t retrieve anything.
  3. If I generate a package.xml with both, the CustomObject and the CustomObjectTranslation inside, the retrieve command retrieves the CustomObject metadata file, a CustomField metadata file, a fieldTranslation metadata field, and raises the error.

@mshanemc
Copy link
Contributor

mshanemc commented Dec 6, 2021

Thanks for the help in narrowing this down do the CustomObjectFieldTranslation (my least favorite metadata type), especially that last investigation. I'm mentioning them here so those issues link to this one.

#1262
#1233

@estrng
Copy link

estrng commented Dec 20, 2021

Does anyone have information about when this issue will be fixed? I'm having some problems with my Project Sprint to the end of the year.

@WillieRuemmele
Copy link
Member

Hi @estrng this is in our current sprint, however, due to the holidays we won't be releasing until the 6th. At the earliest, it would be in the latest-rc build then. There are workarounds mentioned above

@estrng
Copy link

estrng commented Dec 20, 2021

Hi @estrng this is in our current sprint, however, due to the holidays we won't be releasing until the 6th. At the earliest, it would be in the latest-rc build then. There are workarounds mentioned above

Thank you.

@dpuza-formativ
Copy link

Seems there are multiple issues being reported here.

  1. Unexpected child metadata for CustomObject. This will happen when you have metadata that is not part of a CustomObject within a directory containing "objects" in the path. In the examples reported above there are apex classes inside an objects directory. The way the SDR library's metadata file parsing currently works, when trying to categorize the metadata file into a type it will first check if the path matches a well known directory name such as "objects" and if it does, it uses it to determine the type classification. To fix this problem you can remove the "objects" directory from the path. There is an item in the backlog to change the type detection logic to first look at the file suffix to determine the type and that would fix this issue. That fix will come within a few weeks.

@shetzel We're getting the #1, "Unexpected child metadata ... found for parent type [CustomObject]", but it's on this pattern:
\force-app\main\default\objects\X__c\listViews\Y.listview-meta.xml

It appears that if we delete these legitimate files, the errors go away...

@JavierCarvajalLBS
Copy link
Author

Today I´ve received the same error message again using a package.xml file:

Metadata API request failed: Component conversion failed: Unexpected child metadata [\force-app\main\default\objectTranslations\efl__EFL_Child_Objects_List__c-en_US\efl__Object_Name__c.fieldTranslation-meta.xml] found for parent type [CustomObjectTranslation]

If I remove the CustomObjectTranslation type (that previously had the * member inside) from the package.xml file the retrieve operation is successful.

@klouisin
Copy link

klouisin commented Jan 12, 2022

I had the same error. If you have installed extension Salesforce CLI Integration latest version wich is 53.12.0 (or a recent one) you may have this issue. I solved the problem installing an older version : 53.0.0.
Regards

@shetzel
Copy link
Contributor

shetzel commented Jan 13, 2022

The fix is in the latest CLI release published today. sfdx version 7.133.0

@shetzel shetzel closed this as completed Jan 13, 2022
@joaomrsilvaa
Copy link

I had the same issue, the problem for me was Uppercase sensitivity as I wrote FieldTranslation-meta.xml instead of fieldTranslation-meta.xml.

After this change, error disappear when I run sfdx retrieve command.

@cleverlemming
Copy link

I have the same issue trying to update OpportunityLineItem from my org. SFDX, VSCode, and extensions were all updated to latest version today but this made no difference. Error occurs when trying to download metadata for OpportunityLineItem. I think this defect needs to be reopened.

Unexpected child metadata [\src\Objects\OpportunityLineItem\fields\OpportunityLineItem.object-meta.xml] found for parent type [CustomObject]

@cristiand391
Copy link
Member

@cleverlemming this issue was about CustomObjectFieldTranslation which was already fixed. Can you please create a new one?

https://github.com/forcedotcom/cli/issues/new/choose

@wfsanchez
Copy link

I had got the same error.

Unexpected child metadata [random-file.xml] found for parent type [CustomObject]

The problem was that someone misspell the name of the objects folder (Objetcs). After renamed it, all works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests