fix: accept dict-shaped vector params in RestToGrpc converters#1208
fix: accept dict-shaped vector params in RestToGrpc converters#1208wtfashwin wants to merge 1 commit into
Conversation
When a user passes a vectors_config (or sparse_vectors_config, or a VectorParamsDiff) as a raw dict — e.g. parsed from JSON / telemetry — the gRPC path raised AttributeError because the per-param converters expected pydantic models and accessed attributes like `.size` directly. The HTTP path works since pydantic coerces the dict on its own. Coerce the dict to the corresponding pydantic model at the top of the per-param converters so both transports accept the same input shapes. Fixes qdrant#1066
✅ Deploy Preview for poetic-froyo-8baba7 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR adds dict input normalization to three Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Friendly ping — ready |
Summary
When
vectors_config(orsparse_vectors_config, orVectorParamsDiff) is passed as a rawdict— e.g. parsed back from telemetry JSON — the gRPC path fails withAttributeError: 'dict' object has no attribute 'size'. The HTTP path works because pydantic onmodels.CreateCollectioncoerces the dict for free, but the gRPC converters access.size/.distance/.modifierdirectly and assume a fully-validated pydantic model.This PR coerces dict input to the corresponding pydantic model at the top of three converters so both transports accept the same input shapes:
RestToGrpc.convert_vector_paramsRestToGrpc.convert_vector_params_diffRestToGrpc.convert_sparse_vector_paramsCoercing once at the leaf converter is enough —
convert_vectors_config/convert_sparse_vector_config/convert_vectors_config_diffall fan out to these.Fixes #1066
Reproduction (before)
After: works on both
prefer_grpc=Trueand the default HTTP path.Test plan
tests/conversions/test_validate_conversions.pycovering the named-vectors dict case, the single-VectorParamsdict case,VectorParamsDiffdict, andSparseVectorParamsdict — each asserts dict input produces the same gRPC output as the equivalent pydantic-model input.pytest tests/conversions/ -q— 25 passed.mypy qdrant_client/conversions/conversion.py— clean.ruff format --check --line-length=99 qdrant_client/conversions/conversion.py tests/conversions/test_validate_conversions.py— clean.