anancarv / python-artifactory

Typed interactions with the Jfrog Artifactory REST API
MIT License
56 stars 51 forks source link

RemoteRepositoryResponse url field required (type=value_error.missing) #40

Closed gonzaclavell closed 4 years ago

gonzaclavell commented 4 years ago

Hi, In a simple call as :

I tried without verify as well:

art = Artifactory(url="https://uala.jfrog.io/uala", auth=('user','pass'), verify=False) 
remote_repo = art.repositories.get_remote_repo("libs-release")

I'm getting the following error:

Traceback (most recent call last):
  File "/Users/gonzalojavierclavell/Workspace/repository/uala-scripts-actions/scripts/upload-artifactory.py", line 55, in <module>
    remote_repo = art.repositories.get_remote_repo("libs-release")
  File "/Users/xxx/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pyartifactory/objects.py", line 528, in get_remote_repo
    return RemoteRepositoryResponse(**r.json())
  File "/Users/xxx/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pydantic/main.py", line 283, in __init__
    raise validation_error
pydantic.error_wrappers.ValidationError: 1 validation error for RemoteRepositoryResponse
url
  field required (type=value_error.missing)

repos = art.repositories.list() is working fine.

Thanks in advance

anancarv commented 4 years ago

Hi @gonzaclavell ,

Thanks for your feedback :smiley:

After having run some tests, it appears that you're trying to fetch a local or virtual repo with the method get_remote_repo. As its name suggests, this method only fetches remote repositories. I suggest you to check for the type of your repository libs-release, and if it's a local repo, use a get_local_repo instead or get_virtual_repo if it's a virtual repo .

We did implement it this way because, depending on the repository type, the artifactory api returns additional information (e.g. url for remote repos). However, we now see that it can lead to some misunderstandings. So, in a future release, we will add a global action get_repo that will no longer bother with the repository type.

Let me know if you have any questions or suggestions :wink:

anancarv commented 4 years ago

Hi @gonzaclavell, A new release of pyartifactory is available (v1.4.0) with generic methods get_repo, create_repo & update_repo. With this new version, you'll no longer have to bother with the repository since it is automatically detected 😉.