weaviate-ruby icon indicating copy to clipboard operation
weaviate-ruby copied to clipboard

interface conversion: interface {} is nil

Open 1hkr opened this issue 1 year ago • 7 comments

Hi!

For the last 2 weeks I have been having an issue with the get function. All other functions work fine.

Here's a request example: $weaviate_client.query.get class_name: 'Products', where: '{ operator: Equal, valueText: "1-dev", path: ["company"] }', fields: 'product_id', limit: "2"

Response: {"Products"=>["interface conversion: interface {} is nil, not int"]}

It never happened before, and started happening since database version 1.26.4

1hkr avatar Oct 03 '24 14:10 1hkr

@1hkr So is it a change on the Weaviate side?

andreibondarev avatar Oct 03 '24 14:10 andreibondarev

I think so, nothing changed on my end. I'm using sandbox weaviate dbs that I renew every 14 days. The query.get requests on the new sandbox dbs all lead me to this issue.

However, on the weaviate console, the same get requests work fine

1hkr avatar Oct 03 '24 14:10 1hkr

@1hkr Have you tried running against your local self-hosted weaviate? I would probably pose a question in their Slack as well, to try and figure out what changed in the newest version.

andreibondarev avatar Oct 03 '24 14:10 andreibondarev

We get the same error - @1hkr did you ever resolve this? Weaviate don't allow a downgrade that far back.

fearlessfrog avatar Dec 11 '24 22:12 fearlessfrog

I used a workaround: I created a WeaviateHelper running a weaviate graphql_query calling the weaviate API directly.

`require 'net/http' require 'uri' require 'json'

module WeaviateHelper def self.run_graphql_query(query) weaviate_url = Rails.env.development? ? Rails.application.credentials.weaviate_url : ENV['WEAVIATE_URL'] api_key = Rails.env.development? ? Rails.application.credentials.weaviate_api_key : ENV['WEAVIATE_API_KEY'] openai_api_key = Rails.env.development? ? Rails.application.credentials.chatgpt_api_key : ENV['OPENAI_KEY']

uri = URI.parse("#{weaviate_url}/v1/graphql")

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == 'https'

request = Net::HTTP::Post.new(uri.request_uri)
request['Authorization'] = "Bearer #{api_key}"
request['Content-Type'] = 'application/json'
request['X-OpenAI-Api-Key'] = openai_api_key
request.body = { query: query }.to_json

begin
  response = http.request(request)
  if response.code == '200'
    return JSON.parse(response.body)
  else
    Rails.logger.error "GraphQL query failed: #{response.body}"
    return nil
  end
rescue => e
  Rails.logger.error "GraphQL request failed with error: #{e.message}"
  return nil
end

end end`

1hkr avatar Dec 11 '24 22:12 1hkr

Thank you for the reply, looks great and will try that.

fearlessfrog avatar Dec 11 '24 23:12 fearlessfrog

@1hkr , thanks for sharing the WeaviateHelper workaround.

I have been having the same issue with query.get methods and the helper you suggested works great.

stockandawe avatar Jan 13 '25 22:01 stockandawe