# Ansible-galaxy role import results in internal server error

**URL:** <https://forum.ansible.com/t/ansible-galaxy-role-import-results-in-internal-server-error/2812>\
**Category:** Get Help\
**Tags:** galaxy-ng\
**Created:** [December 8, 2023, 5:15pm UTC](https://forum.ansible.com/t/ansible-galaxy-role-import-results-in-internal-server-error/2812 "2023-12-08T17:15:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lkiesow](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/lkiesow/32/941_2.png) [@lkiesow](https://forum.ansible.com/u/lkiesow)\
**Post date:** [December 8, 2023, 5:15pm UTC](https://forum.ansible.com/t/ansible-galaxy-role-import-results-in-internal-server-error/2812/1 "2023-12-08T17:15:07Z")

</div>

I’m currently trying (and failing) to update one of my roles in Galaxy:

```auto
❯ ansible-galaxy role import --token "${TOKEN}" --role-name uos.smb_backup virtuos smb_backup               
ERROR! None (HTTP Code: 500, Message: Internal Server Error)

```

The token should be valid and changing it will result in a 403 Forbidden:

```auto
❯ ansible-galaxy role import --token "123" --role-name uos.smb_backup virtuos smb_backup                                                                                                                                                      
ERROR! Error when finding available api versions from default (https://galaxy.ansible.com) (HTTP Code: 403, Message: Forbidden)

```

Not sure what I’m doing wrong. Given that it is an internal server error, it seems like the API is currently broken?

---

<div class="post-metadata">

**Author:** ![atul\_mohan](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@atul\_mohan](https://forum.ansible.com/u/atul_mohan)\
**Post date:** [January 21, 2025, 6:17am UTC](https://forum.ansible.com/t/ansible-galaxy-role-import-results-in-internal-server-error/2812/2 "2025-01-21T06:17:44Z")

</div>

```auto
#!/bin/bash

# Define variables
TOKEN="your_valid_token_here"
GITHUB_USER="virtuos"
GITHUB_REPO="smb_backup"
ROLE_NAME="uos.smb_backup"

# Function to import role
import_role() {
    # Attempt to import the role with the provided token
    echo "Attempting to import role $ROLE_NAME from $GITHUB_USER/$GITHUB_REPO..."
    ansible-galaxy role import --token "$TOKEN" --role-name "$ROLE_NAME" "$GITHUB_USER" "$GITHUB_REPO"
    
    # Check the exit status of the command
    if [$? -eq 0]; then
        echo "Role import was successful."
    else
        echo "Role import failed."
    fi
}

# Function to test with an invalid token for comparison
test_invalid_token() {
    # Using an intentionally invalid token to check for Forbidden response
    INVALID_TOKEN="123"
    echo "Testing with invalid token to ensure proper authentication error..."
    ansible-galaxy role import --token "$INVALID_TOKEN" --role-name "$ROLE_NAME" "$GITHUB_USER" "$GITHUB_REPO"
    
    # Check for expected 403 Forbidden response
    if [$? -ne 0]; then
        echo "Received expected authentication error."
    else
        echo "Unexpected success with invalid token."
    fi
}

# Main execution
echo "Starting role import procedure..."
import_role
echo "Now testing with an invalid token for comparison..."
test_invalid_token

echo "If you continue to see 'Internal Server Error', the issue might be on the server side. Here are some steps to take:"
echo "- Check if there are known issues with Galaxy API from the Ansible community or forums."
echo "- Ensure your network connection is stable."
echo "- Try importing at a different time or from a different network to rule out temporary issues."
echo "- Look into the role's meta/main.yml file for any syntax errors or issues with the role structure."
echo "- If possible, check server logs on Galaxy if you have access or contact support."

# Note: If you need to debug further, you might add verbose logging:
# ansible-galaxy role import --token "$TOKEN" --role-name "$ROLE_NAME" "$GITHUB_USER" "$GITHUB_REPO" -vvv

```
