Unable to find end tag at: START_TAG

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

"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""

From that error you can get the necessary information to find the problem and fix it. Let's analyse the error:

1. The issue happened when using the git snapshot with Id: XXXXXXXXXXXXXXX. A specific component committed with that git snapshot is causing issues.
2. The component causing the issue is provided in the error. The problem is related to the file 'FileName' in Git.
3. If you were committing in a user story, check the affected file in the master branch and source branch. If you were committing in the git snapshot directly, check the source branch.
4. There is something not supported in that xml file, specifically on the line "LineNumber" provided in the error.

You need to identify the piece of data that is incorrect in the .xml file and fix it. That could be:

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.

Once the offending .xml file is fixed, try the same operation again and this time is should succeed. 
Please note that 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?