Unable to find end tag at: START_TAG

When working with Copado,you may come across any of the errors below or similar.

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 if 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 analyze 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 to a user story, look for the affected file in the master branch and the source branch. If you are committing in the Git snapshot directly, check the source branch.

  4. There must be something that is not supported in that xml file, specifically in 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 in the destination branch.

  4. There must be something that is not supported in that xml file, specifically in the line "LineNumber" provided in the error.

Potential causes of a broken xml file are:

  1. Incorrect characters that were added when manually editing the file 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. Tags must be ordered alphabetically in .xml files.

  3. Duplicate tags, tags that were closed twice or left open, or any typo in the tags.

  4. Unsupported tags, for instance <picklist>, which was deprecated in API version 38. Check out Salesforce’s article Picklist (Including Dependent Picklist) for more information.

  5. Unsupported tag values. This would be any value in a tag that is not supported by the Metadata API, for example the commented Gender value in the translation files. Check out the article Error: Not a valid enumeration for type: class com.sforce.soap.metadata.Gender for more information.

Once the offending .xml file is fixed, try the same operation again and this time it should be completed successfully.

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


How did we do?