batch insert fails the whole batch with "ValueError: Unexpected type" when a value is a Decimal

Aberta
#2,263 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@steven-asearcy já está trabalhando nisso.

Desde 18/11/2026.

  • #2264 de @steven-asearcy — aberto

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
35/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Estagnada
Stack de tecnologia
python

Direção de pesquisa

Start with _serialize_primitive in collections/batch/grpc_batch.py and compare its handling of unsupported values with the data.insert error described in the issue. Check the existing batch serialization tests and add coverage for decimal.Decimal and numpy.float32; done means these values produce a clear WeaviateInvalidInputError. Pull request #2264 is already open for this issue.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

ran into this in a singer target. the singer sdk parses json numbers as decimal.Decimal, and postgres numeric columns come back as Decimal through psycopg too, so probably not just me.

data.insert gives a clear error:

WeaviateInvalidInputError: Invalid input provided: Cannot serialize value of type <class 'decimal.Decimal'> to Weaviate..

the grpc paths don't. insert_many raises ValueError: Unexpected type from inside protobuf, and the batch context managers just log it. every object in that batch ends up in failed_objects, including the good ones:

with col.batch.fixed_size(batch_size=100) as batch:
    for i in range(99):
        batch.add_object({"price": float(i)})
    batch.add_object({"price": Decimal("9.99")})

len(col.batch.failed_objects)  # 100
len(col)                       # 0

the message doesn't say which property or type it was, so it's hard to track down.

cause is _serialize_primitive in collections/batch/grpc_batch.py. it passes anything it doesn't handle straight to Struct.update. numpy.float32 hits the same thing.

weaviate-client 4.24.1, weaviate 1.40.5, python 3.13

i'll put up a PR that raises the same WeaviateInvalidInputError as data.insert. one bad value would still fail the whole batch after that, which felt like a bigger change so i left it alone. can take a look at that too if you want.

Linguagem predominante
Python
Estrelas
230
Forks
173
Merge médio
4d 16h
PRs com merge (30d)
23

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de weaviate/weaviate-python-client

Todas as issues de weaviate/weaviate-python-client

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.