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

fix: Resolve failing tests after pydantic V2 merge #5700

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions argilla-server/src/argilla_server/api/schemas/v1/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ def validate_chat_field_content(cls, fields: Any):
fields[key] = [
item if isinstance(item, ChatFieldValue) else ChatFieldValue(**item) for item in value
]
except TypeError as e:
raise ValueError(f"Error parsing chat field '{key}': {e}")
except ValidationError as e:
raise ValueError(f"Error parsing chat field '{key}': {e.errors()}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -744,19 +744,19 @@ async def test_create_dataset_records_bulk_with_wrong_custom_field_value(
"params": {
"errors": [
{
"loc": ["body", "items", 0, "fields", "text-field"],
"msg": "str type expected",
"type": "type_error.str",
"loc": ["body", "items", 0, "fields", "text-field", "constrained-str"],
"msg": "Input should be a valid string",
"type": "string_type",
},
{
"loc": ["body", "items", 0, "fields", "text-field"],
"msg": "value is not a valid list",
"type": "type_error.list",
"loc": ["body", "items", 0, "fields", "text-field", "list[ChatFieldValue]"],
"msg": "Input should be a valid list",
"type": "list_type",
},
{
"loc": ["body", "items", 0, "fields", "text-field"],
"msg": "value is not a valid dict",
"type": "type_error.dict",
"loc": ["body", "items", 0, "fields", "text-field", "dict[constrained-str,any]"],
"msg": "Input should be a valid dictionary",
"type": "dict_type",
},
]
},
Expand All @@ -771,19 +771,19 @@ async def test_create_dataset_records_bulk_with_wrong_custom_field_value(
"params": {
"errors": [
{
"loc": ["body", "items", 0, "fields", "text-field"],
"msg": "str type expected",
"type": "type_error.str",
"loc": ["body", "items", 0, "fields", "text-field", "constrained-str"],
"msg": "Input should be a valid string",
"type": "string_type",
},
{
"loc": ["body", "items", 0, "fields", "text-field"],
"msg": "value is not a valid list",
"type": "type_error.list",
"loc": ["body", "items", 0, "fields", "text-field", "list[ChatFieldValue]"],
"msg": "Input should be a valid list",
"type": "list_type",
},
{
"loc": ["body", "items", 0, "fields", "text-field"],
"msg": "value is not a valid dict",
"type": "type_error.dict",
"loc": ["body", "items", 0, "fields", "text-field", "dict[constrained-str,any]"],
"msg": "Input should be a valid dictionary",
"type": "dict_type",
},
]
},
Expand All @@ -798,19 +798,19 @@ async def test_create_dataset_records_bulk_with_wrong_custom_field_value(
"params": {
"errors": [
{
"loc": ["body", "items", 0, "fields", "text-field"],
"msg": "str type expected",
"type": "type_error.str",
"loc": ["body", "items", 0, "fields", "text-field", "constrained-str"],
"msg": "Input should be a valid string",
"type": "string_type",
},
{
"loc": ["body", "items", 0, "fields", "text-field"],
"msg": "value is not a valid list",
"type": "type_error.list",
"loc": ["body", "items", 0, "fields", "text-field", "list[ChatFieldValue]"],
"msg": "Input should be a valid list",
"type": "list_type",
},
{
"loc": ["body", "items", 0, "fields", "text-field"],
"msg": "value is not a valid dict",
"type": "type_error.dict",
"loc": ["body", "items", 0, "fields", "text-field", "dict[constrained-str,any]"],
"msg": "Input should be a valid dictionary",
"type": "dict_type",
},
]
},
Expand All @@ -826,8 +826,10 @@ async def test_create_dataset_records_bulk_with_wrong_custom_field_value(
"errors": [
{
"loc": ["body", "items", 0, "fields"],
"msg": "argilla_server.api.schemas.v1.chat.ChatFieldValue() argument after ** must be a mapping, not str",
"type": "type_error",
"msg": "Value error, Error parsing chat field 'text-field': "
"argilla_server.api.schemas.v1.chat.ChatFieldValue() "
"argument after ** must be a mapping, not str",
"type": "value_error",
}
]
},
Expand Down Expand Up @@ -871,7 +873,7 @@ async def test_create_dataset_records_bulk_with_wrong_text_field_value(
},
)

assert response.status_code == 422
assert response.status_code == 422, response.json()
assert response.json() == expected_error
assert (await db.execute(select(func.count(Record.id)))).scalar_one() == 0

Expand Down
Loading