-
Notifications
You must be signed in to change notification settings - Fork 78
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
Projects missing .objectTranslation when having .fieldTranslation fail on CLI/VSCode operations #2813
Comments
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. |
Hey @evan-cm - how old was the "old" version of the CLI you were using? Over the years we've had to adjust, fix, or redo how metadata was represented locally, and sometimes it's not always backwards compatible. During the transitions we've always warned and given appropriate time to adjust or prepare for a difference. If you update to the latest, as of last week, you can customize how metadata is represented locally using our Custom Decomposition. |
This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted. |
@WillieRuemmele It appears the old CLI version is 7.119.2 ~3 years old. While I'm not sure the Custom Decomposition is helpful here, I appreciate you calling it out as it looks like a neat feature that I'm interested in playing with. While I understand metadata format may change (I don't believe this is exactly what happened here), I believe my two suggestions still apply as they expand beyond this issue and helps address the general class of errors this error falls into. A project shouldn't be completely unusable because one component somewhere is malformed. Why does apex code manipulations break when an unrelated component is malformed? Warning the user on unrelated operations, and breaking on operations on that metadata makes sense to me. This would help alleviate these sorts of issues: https://github.com/forcedotcom/cli/issues?q=is%3Aissue+Unexpected+child+metadata. I also wonder about the efficiency of validating the entire package on every command, although I haven't noticed performance issues so maybe that doesn't matter. On top of that, the error is a little confusing for the user. It feels weird that the tooling cannot infer the parent metadata from the folder name seeing as the objectTranslation file shares the name as the containing folder. To reiterate, my two suggestions for fixes are:
As an aside, if anyone else is wanting to mass generate the blank objectTranslation files, this is a shell script to do so. Note that I'd still validate and ensure deploying the blank objectTranslation file does what you expect: for brokenFile in $(diff <(for x in force-app/main/default/objectTranslations/*/*.objectTranslation-meta.xml; do echo "$(dirname "$x")" ; done) <(printf "%s\n" force-app/main/default/objectTranslations/*) | grep ">" | sed 's!> force-app/main/default/objectTranslations/!!' )
do
echo "Creating force-app/main/default/objectTranslations/$brokenFile/$brokenFile.objectTranslation-meta.xml"
printf "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<CustomObjectTranslation></CustomObjectTranslation>\n" > force-app/main/default/objectTranslations/$brokenFile/$brokenFile.objectTranslation-meta.xml
git add force-app/main/default/objectTranslations/$brokenFile/$brokenFile.objectTranslation-meta.xml
done |
@evan-cm I've been thinking through your ideas.
it's not exactly what you're thinking (that we're doing a scan for project validation purposes). There are a few reasons we "resolve" stuff in the project before a retrieve
I see your point, that for both 1 and 2, we could be more selective about what we scan (ex: we figure out what's in your retrieve flags and THEN use that information to resolve a only a subset of the local project). As far as "why is the parent file COT required, anyway" ? Here's the metadata API docs COFT are children of COT to the metadata API. It wants a file for the COT, and all the COFT are an array of props inside that file. It's safer/cleaner/more deterministic to roll up the COFT files into the COT and deploy that as whole. If we were to create a COT file empty, and then add only your COFT, I'm not sure how the API interprets that. Does that mean "only update what is different (the COFT)?" or does it mean, "clear the Anyone else seeing breaking changes for CO(F)T? |
This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted. |
Summary
Projects created by earlier versions of the CLI do not create an empty .objectTranslation file even when there is a .fieldTranslation file. This results in modern versions of the CLI throwing an "Unexpected child metadata" error on any operation, even those not including that metadata. This means the developer is unable to do various actions, such as retrieving metadata using the org browser via VS Code. Note this includes operations that don't touch the CustomObjectTranslation.
My suggestion is twofold:
Example error:
Error (1): Unexpected child metadata [/force-app/main/default/objectTranslations/Asset-en_US/asset_address.fieldTranslation-meta.xml] found for parent type [CustomObjectTranslation]
Steps To Reproduce
Creating a broken project using sfdx:
npx sfdx force:source:retrieve -x package.xml --verbose
Creating a broken project using updated commands:
sf project retrieve start --manifest package.xml
Getting error with the broken project:
Expected result
Command should complete without errors. Throwing warnings make more sense in this context.
Actual result
Command throws error:
Error (1): Unexpected child metadata [/force-app/main/default/objectTranslations/Asset-en_US/asset_address.fieldTranslation-meta.xml] found for parent type [CustomObjectTranslation]
System Information
Additional information
Related stories:
Unexpected child metadata
in sharing rules and permission sets #2804Project file: ObjTranslationIssues.zip
Doctor debug.log 1712590744871-command-debug.log
Stack trace from doctor debug log:
Workaround involves deleting objectTranslations folder (works as long as you don't need to commit changes against it). This will cause git to throw a fit, so here is the workaround I found. Note you have to run this whenever changing branches:
find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && pwd && git ls-files -z ${pwd} | xargs -0 git update-index --skip-worktree" \;
The text was updated successfully, but these errors were encountered: