Error: Not a valid enumeration for type: class com.sforce.soap.metadata.Gender
When working with Copado, you might receive an email with the details below:
"Details: Status: Broken-Xml-File(s)
Error loading metadata file 'ObjectName__c-da.objectTranslation': Not a valid enumeration for type: class com.sforce.soap.metadata.Gender".
Let's analyze this error:
"Broken-Xml-Files(s)": This means that one or more .xml files in Git contain incorrect data.
Which file(s) is/are incorrect? If you continue to review the information in the email, you will see “Error loading metadata file 'ObjectName__c-da.objectTranslation':” This is the file that is broken in Git.
What exactly is broken? This piece of information is also provided in the error: “Not a valid enumeration for type: class com.sforce.soap.metadata.Gender”. The value of the gender tag included in the file above is incorrect.
Now that you know which file is failing in Git and why, you need to find out in what branches the file is broken, since the file might exist in different branches in your repository. You can start by checking the branches involved in the operation you were performing when you received this error:
If you were committing in a user story, check the file concerned both in the master branch and in the source branch.
- If you were promoting and/or deploying, check the file concerned in the feature branch, in the promotion branch and in the destination branch.
This issue is most likely being caused by the value <!-- Neuter --> in the <gender></gender> tag of the .xml file provided in the error, since this type of value is not supported and is breaking the .xml file.
When retrieving the object translation and the corresponding object, the object translation .xml file retrieved by Salesforce’s Metadata API contains the values that are not translated and are added in the tags with comments. This is causing an issue with a particular tag: <gender><!-- Neuter --></gender>.
The value <!-- Neuter --> in this tag is not parsed by the Salesforce java libraries and it's causing issues.
These commented values are retrieved by Salesforce’s Metadata API, but Copado is not adding any of them.
How to Avoid This Issue in the Future
The Global Find and Replace Rules feature can be used to ensure the value <!-- Neuter --> is never committed again into the translation file.
Please note that creating or editing rules and regex in this file is out of the scope of Copado Support. If you need help with this configuration, our Professional Services team will be able to assist you. Contact your customer success manager for more information.
Below you will find two examples of rules that can be used in this case. These rules have been added as images to avoid issues with hidden characters when copying and pasting:
Remove the tag <gender><!-- Neuter --></gender> completely:
Replace <gender><!-- Neuter --></gender> with <gender>Neuter</gender>: