Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: type object 'VaultOverview' has no attribute 'model_validate' #109

Closed
alavi-sorrek opened this issue Sep 10, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@alavi-sorrek
Copy link

Scenario & Reproduction Steps

Seems any time I try to list vaults or list items using the docs' suggestions, I'm thrown an attribute error related to model_validate for both items and vaults.

pip install git+https://github.com/1Password/[email protected]#egg=onepassword

import asyncio
from onepassword.client import Client

async def get_items():
    client = await Client.authenticate(auth=token, integration_name="secret_loader", integration_version="v1.0.0")
    vaults = await client.vaults.list_all()
    async for vault in vaults:
        print(vault.title)
        items = await client.items.list_all(vault.id)
        async for item in items:
            print(item.title)


asyncio.run(get_items())

Actual Behavior

AttributeError: type object 'VaultOverview' has no attribute 'model_validate'

Expected Behavior

I'm expecting to retrieve information related to vaults and items in them that are associated with my account

SDK version

No response

Additional information

No response

@alavi-sorrek alavi-sorrek added the bug Something isn't working label Sep 10, 2024
@hculea
Copy link
Member

hculea commented Sep 12, 2024

Hi @alavi-sorrek , thank you for reaching out. Can you please give me a few more details related to:

  • the platform where you are running the SDK (OS + arch)
  • the Python version that you use
  • if you are running in any virtual environment, or if you use a pyproject.toml manifest to declare your project's dependencies

Looking forward to hearing back from you!

@alavi-sorrek
Copy link
Author

alavi-sorrek commented Sep 12, 2024 via email

@MOmarMiraj
Copy link
Contributor

Hi @alavi-sorrek,

We pushed a fix for a bad commit when installing the Python SDK. Could you please retry and let me know if the error is still happening. If so, I have some follow up questions:

  1. Did you try running the example.py code and does that work fine?
  2. What version of pydantic are you using?

Looking forward to hearing from you!

@alavi-sorrek
Copy link
Author

alavi-sorrek commented Sep 24, 2024 via email

@kumarnmanoj
Copy link

kumarnmanoj commented Oct 4, 2024

Hi @MOmarMiraj

We tried to list the vault and facing the same error. We followed the installation instructions provided in the README.

File "/.venv/lib/python3.10/site-packages/onepassword/vaults.py", line 28, in list_all
    objects = [VaultOverview.model_validate(data) for data in response_data]
File "/.venv/lib/python3.10/site-packages/onepassword/vaults.py", line 28, in <listcomp>
    objects = [VaultOverview.model_validate(data) for data in response_data]
AttributeError: type object 'VaultOverview' has no attribute 'model_validate'

Python Version - 3.10.7
pydantic = "^1.10.7"

@MOmarMiraj
Copy link
Contributor

MOmarMiraj commented Oct 4, 2024

Hi @kumarnmanoj

Thanks for looking into this deeper and sorry your having trouble with this still.

It seems that the issue is your pydantic version. The minimum version of pydantic that the SDK requires is v2.5. Is it possible you update your pydantic version to a version thats greater than v2.5 and try again?

This is a dependancy we do not currently document and we will address this soon.

@kumarnmanoj
Copy link

Hi @MOmarMiraj

Thanks for the quick reply. We upgraded the pydantic to the latest version and it worked perfectly.

Thanks again.

@MOmarMiraj
Copy link
Contributor

Im glad I could fix it, I will close the issue as this has been resolved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants