Closed tradzero closed 1 year ago
Dear @tradzero, thank you for bringing this to our attention. I have created a pull request to fix the problem, which involves returning null instead of an empty string. It appears that the getName method is used for building search requests and batch operations, as well as the toArray method. I guess, these changes will cover the problem. Could you review the PR?
@hkulekci it looks good to me, thanks for fix this!
Summary
TypeError encountered in
Qdrant\Models\VectorStruct::getName()
when the$name
attribute is null.Description
When an instance of
VectorStruct
is created with only the$vector
argument provided and$name
left as null, a TypeError occurs with the following message:TypeError Qdrant\Models\VectorStruct::getName(): Return value must be of type string, null returned.
The issue seems to arise from the
getName()
method, which expects to return a string. However, when$name
is null, it does not meet this expectation.The error was resolved by modifying the
getName()
function to return an empty string when$name
is null, like this:$this->name ? $this->name : '';
Environment
Steps to Reproduce
VectorStruct
with only the$vector
argument provided, leaving$name
as null.getName()
method on this instance.Expected Behavior
If the
$name
argument is not provided when instantiatingVectorStruct
, calling thegetName()
method should either not cause a TypeError, or it should be documented that providing a$name
is required.Actual Behavior
A TypeError is thrown when
getName()
is called on an instance ofVectorStruct
that was instantiated with$name
as null.Possible Fix
Modify the
getName()
function to return an empty string when$name
is null. This would look like:$this->name ? $this->name : '';