ARTIFACTORY: How to resolve system import failures caused by active Federated repositories

AuthorFullName__c
Ino Choi
articleNumber
000005829
FirstPublishedDate
2023-07-20T17:07:17Z
lastModifiedDate
2025-05-21

ARTIFACTORY: How to resolve system import failures caused by active Federated repositories

Affected Versions: Artifactory 7.18.3 and above

Description

When performing a system import in Artifactory, you may encounter issues if there are active Federated repositories configured. These Federated repositories are configured to establish connections with existing member JPDs in the exported data, which can potentially disrupt the import process. If this situation arises, you may come across the following error message in the logs:

2023-01-01 00:00:00,000 [ERROR] (o.a.a.c.ImportExportStatusHolder:43) Failed system import
org.artifactory.rest.exception.RestException: Failed to add the following remote repositories to the federation:
http://<MEMBER_JPD_URL>/artifactory/generic-local: Validation of federated repository failed: generic-local cannot be added to the federation as it is a member of another federation.


However, there are steps you can take to resolve this issue and ensure a successful system import. In this article, we will explore the necessary actions to overcome this challenge and complete the system import.

 

Resolution

Remove Federated members

On the source Artifactory instance, you can find the member JPD repositories listed under the Federated repository settings page.

User-added image

To remove Federated members, you can create a script that iterates through the list of Federated repositories and executes a curl command. Here is an example:

#!/bin/bash

artifactory="<ARTIFACTORY_URL>"
username="<USERNAME>"
password="<PASSWORD>"
repository_file="repo_list.txt"

# Step 1: Save the list of repositories to a file
curl -u $username:$password "$artifactory/artifactory/api/repositories?type=federated" | jq -r '.[].key' > $repository_file

# Step 2: Iterate through the repository list and disable federated members
while IFS= read -r repository; do
    # Construct the curl command with the repository value
    curl_command="curl -u "$username:$password" -XPOST $artifactory/artifactory/api/repositories/$repository -H \"Content-Type: application/json\" -d '{\"members\":[]}'"

    # Print the comment
    echo "Disabling federated member for repository: $repository"

    # Execute the curl command
    eval $curl_command

    # Add a new line
    echo ""

done < "$repository_file"

# Remove the repository file
rm $repository_file


Run the script and we can see that the member repos have been removed.

$ ./remove_members.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   530    0   530    0     0  12325      0 --:--:-- --:--:-- --:--:-- 12325
Disabling federated member for repository: federated-local
Repository federated-local update successfully.

Disabling federated member for repository: generic-local
Repository generic-local update successfully.

Disabling federated member for repository: test-federated
Repository test-federated update successfully.


User-added image

Remove Binding Tokens

Navigate to the Administration module - Platform Management - Deployment Bindings page and remove the existing bindings tokens under the Federated Repository tab. Please note that you can reconfigure and add them back once the export process is completed. (Ref: Binding Tokens)

User-added image

Deactivate Artifactory key encryption

To prevent the occurrence of the "Given final block not properly padded" error during the import process, refer to the knowledge base article available here to disable the Artifactory key encryption.

Now, you can proceed to create the system export data from the source Artifactory instance and import it into the target Artifactory instance. (Ref: Import and Export)