Azure DevOps – File patterns are not supported for this policy type (TF402457)

Reading Time: 2 minutes

While configuring branch policies in Azure DevOps Server, I encountered a frustrating and somewhat cryptic error message: TFS.WebApi.Exception: TF402457: The settings for this policy are not correctly formatted. Error: File patterns are not supported for this policy type.


👾 What does this error mean?
This error occurs when attempting to apply file path filters (also known as file patterns) to a branch policy type that does not support them in Azure DevOps Server 2020 Update 1.2. It’s currently unclear whether this behavior is an intentional limitation or a bug that has been addressed in newer Azure DevOps Server releases. Since I wasn’t able to find a clear solution online, I thought it would be helpful to share a quick workaround based on my experience. If you encounter this behaviour with newer DevOps server releases as well please leave a comment.

🔍 Root Cause
The branch policy UI let you define a policy (Build Validation) and include file path filters. You can specify absolute paths (path must start either by / or a wildcard).

You can specify multiple paths using ; as a separator. 

I was able to create a Build Validation policy and configure the path filter without any issues. However, as soon as I enabled an additional setting under Branch Policies, such as “Require a minimum number of reviewers”, I encountered the following error:

Initially, I attempted to use Build Validation with file path filters on its own without enabling any reviewer requirements which left me puzzled, as the policy consistently failed to work without providing a clear reason. It wasn’t until I combined it with the reviewer policy that the system finally revealed the underlying issue.

âś… Workaround
When configuring the path filter through the Azure DevOps web portal, it appears that the paths may be improperly formatted, which causes issues on the backend and leads to errors like TF402457. If you need to work with Build Validation policies that include path filters, and want to avoid these problems, I recommend using the Azure DevOps CLI, which handles the configuration more reliably and allows for greater control over the policy setup.

Step 1 – Prepare Azure DevoOps CLI

Step 2 – Identify Repository ID

Step 3 – Filter Branch Policies

Step 4 – Identitfy Branch Policy

Step 5 – Configure Path Filter

Leave a Reply

Your email address will not be published. Required fields are marked *