ARTIFACTORY: Why am I getting “Expected a file but found a folder” error?

Fadi Rouhana
2022-10-03 09:32

You may encounter the "Expected a file but found a folder" error when setting up replication between repositories in Artifactory. What does this error mean?

This error occurs when you have a file with the same name as a folder that you are trying to replicate in the target instance, and Artifactory is not able to overwrite it. For example, let's take the following case:

  1. We create two repositories in two Artifactory instances
  2. In Artifactory B (target instance), we deploy a file with this path “generic-local/test/file.ext” 
  3. In Artifactory A (source instance), we deploy a file named "test" under “generic-local”
  4. We configure a push replication from the “generic-local” in Artifactory A to the one residing in Artifactory B instance
  5. After triggering replication between those repositories, you will observe the following error:

An error occurred while performing folder replication for 'generic-local:': Expected a folder but found a file, at: generic-local:test

This is the expected behavior, as Artifactory behaves as a Linux filesystem, so if there is a directory in the target with the same name as the file you are trying to deploy, then the above error will be printed.

Hence, if you encounter the “Expected a file but found a folder” error, you will need to verify that there are no directories in the target instance with the same name as the files failing to replicate from the source instance. Then, you may trigger the replication once again and monitor the logs found under $JFROG_HOME/artifactory/var/log/artifactory-service.log to ensure that your replication has been completed successfully with no issues.