You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Document.save() throws error on pydnticV2.HttpUrl type fields
To Reproduce
frombeanieimportDocument, init_beaniefrompydanticimportHttpUrlfrommotor.motor_asyncioimportAsyncIOMotorClientimportosclassData(Document):
link: HttpUrlMONGO_URI=os.environ.get("MONGO_URI", "mongodb://localhost:27017/")
asyncdefconfig_db():
# Create Motor clientclient=AsyncIOMotorClient(MONGO_URI)
# Init beanie with the Product document classawaitinit_beanie(
database=client["test"],
document_models=[
Data,
],
)
awaitconfig_db()
data=Data(link="https://www.google.com")
awaitdata.save()
error message:
File [venv/lib/python3.9/site-packages/beanie/odm/utils/encoder.py:244), in Encoder._encode(self, obj)
243 try:
--> 244 data = dict(obj)
245 except Exception as e:
TypeError: 'pydantic_core._pydantic_core.Url' object is not iterable
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
File [venv/lib/python3.9/site-packages/beanie/odm/utils/encoder.py:248](venv/lib/python3.9/site-packages/beanie/odm/utils/encoder.py:248), in Encoder._encode(self, obj)
247 try:
--> 248 data = vars(obj)
249 except Exception as e:
TypeError: vars() argument must have __dict__ attribute
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
[24](line=23) await config_db()
[26](line=25) data = Data(link="https://www.google.com/")
...
250 errors.append(e)
--> 251 raise ValueError(errors)
252 return self._encode(data)
ValueError: [TypeError("'pydantic_core._pydantic_core.Url' object is not iterable"), TypeError('vars() argument must have __dict__ attribute')]
Expected behavior
save runs without error out
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
Describe the bug
Document.save() throws error on pydnticV2.HttpUrl type fields
To Reproduce
error message:
Expected behavior
save runs without error out
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: