Unable to find end tag at: START_TAG

You might receive the errors below, or similar, when working with Copado.

Error #1:
"Details: Unexpected Error while taking a Snapshot. Id: XXXXXXXXXXXXXXX.
Message: Error loading metadata file 'FileName' unable to find end tag at: START_TAG seen ...\n ... @"LineNumber""


Error #2:
"Details:  Merge of User Story feature branches was unsuccessful. Status: Broken-Xml-File(s)
Error loading metadata file 'FileName': unable to find end tag at: START_TAG seen ...\n ... @"LineNumber"
Copado tip: The branch feature/US-XXXXXXX could not be merged into promotion/PXXXXXX-DeploymentName because the are conflicting files."


The errors above will be displayed when any of the branches that are being merged contains a broken xml file. You will need to fix the broken file and try the operation again.
From the errors you can get the necessary information to find the problem and fix it. Let's analyse both errors:

Error #1:
  1. The issue happened during the commit process using the git snapshot with Id: XXXXXXXXXXXXXXX. 
  2. The component causing the issue is provided in the error. The problem is related to the file 'FileName' in Git.
  3. If you are committing in a user story, look for the affected file in the master branch and source branch. If you are committing in the git snapshot directly, check the source branch.
  4. There must be something not supported in that xml file, specifically on the line "LineNumber" provided in the error.
Error #2:
  1. The issue happened during the promotion process.
  2. The component causing the issue is provided in the error. The problem is related to the file "FileName" in Git.
  3. Look for the affected file in the "feature/US-XXXXXXX" branch and "promotion/PXXXXXX-DeploymentName" branch. If the affected file belongs to the promotion branch, the real affected file is on the target branch.
  4. There must be something not supported in that xml file, specifically on the line "LineNumber" provided in the error.
Potential causes of a broken xml file are:
  1. Incorrect characters that were added when editing the file manually in Git. Someone could have edited the file in git leaving incorrect data.
  2. Tags that are located in the wrong place in the file. The tags must be ordered alphabetically in the .xml files.
  3. Duplicate tags, tags that were closed twice or left open or any typo in the tags. 
  4. Unsupported tags like <picklist> that is deprecated since the API version 38. More info here.
  5. Unsupported tag values. This would be any value in a tag not supported by the Metadata API for example the commented Gender value in the translation files. More information here.

Once the offending .xml file is fixed, try the same operation again and this time is should succeed. 

NOTE:
You might need to fix several problems in the same file or different files so, if you receive the same error after doing some fixes, check the line and the file since they could be different then the previous error what means that you fixed one problem but not all of them.
 

How did we do?