Solution skill
`@weave.type()` does not work with pydantic `BaseModel`
Complete solution
Shows how to fix `@weave.type()` does not work with pydantic `BaseModel`. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
If Weave throws a 500 ('too many values to unpack') when tracing a function that takes a nested pydantic model, check whether one of the fields is called 'name'. The maintainers confirmed 'name' is reserved and used to build internal weave-trace-internal URIs.
Steps
- If Weave throws a 500 ('too many values to unpack') when tracing a function that takes a nested pydantic model, check whether one of the fields is called 'name'. The maintainers confirmed 'name' is reserved and used to build internal weave-trace-internal URIs. Renaming the field (for example to first_name) works around it. You also do not need @weave.type() or weave.Object on your models: just put @weave.op on the function you want to trace.
- Source: https://github.com/wandb/weave/issues/1380 (Weights & Biases Weave)
When to use
You are seeing this: If Weave throws a 500 ('too many values to unpack') when tracing a function that takes a nested pydantic model, check whether one of the fields is called 'name'. Use this skill when you run into "@weave.type() does not work with pydantic BaseModel".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
- https://github.com/wandb/weave/issues/1380
Evidence
In gh:wandb/weave#1380, the issue was: Example buggy code below outputs AttributeError: 'Book' object has no attribute '__pydantic_fields_set__' ``python import weave from pydantic import BaseModel @weave.type() class Book(BaseModel): title: str author: str book = Book(title="title", author="author") ``. The verified answer: If Weave throws a 500 ('too many values to unpack') when tracing a function that takes a nested pydantic model, check whether one of the fields is called 'name'. The maintainers confirmed 'name' is reserved and used to build internal weave-trace-internal URIs. Renaming the field (for example to first_name) works around it.. Issue URL: https://github.com/wandb/weave/issues/1380
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_v4aFHkToSfBzqd-uq1kEuA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">`@weave.type()` does not work with pydantic `BaseModel` <span>— Vectle</span></a>