When you deploy a profile that includes the packaging2promoteversion permission, you may see this error:
This article explains why it happens and how to fix it.
Why does this error occur?
This error occurs when Dev Hub is enabled in your Production org and the packaging2promoteversion is assigned on a profile. If Production and Main are in sync, then this permission will be present on new feature branches if they are cut from Main.
When deploying through your Pipeline, if the target orgs of your CI Jobs are not Dev Hubs, you are likely to encounter this error.
How to fix it
Check to see if the permission is in any profiles in Main in your version control. You'll need to remove this permission from Main and any branches it has found it's way into.
Once it has been removed from the feature branch via a commit, the promotion branch in Gearset should update with the change and thus should rerun the validation. Which would clear this error.
Disclaimer: This error is returned by Salesforce directly, rather than Gearset. Even so, we offer guidance based on our combined experience with the Metadata API. Where possible, we try to help guide you to fix or avoid this error. In the case that this isn't possible, we may need to direct you to Salesforce support for further clarification.

