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

interface conversion: interface {} is nil #63

Open
1hkr opened this issue Oct 3, 2024 · 7 comments
Open

interface conversion: interface {} is nil #63

1hkr opened this issue Oct 3, 2024 · 7 comments

Comments

@1hkr
Copy link

1hkr commented Oct 3, 2024

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

@andreibondarev
Copy link
Collaborator

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

@1hkr
Copy link
Author

1hkr commented Oct 3, 2024

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

@andreibondarev
Copy link
Collaborator

@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.

@fearlessfrog
Copy link

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

@1hkr
Copy link
Author

1hkr commented Dec 11, 2024

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`

@fearlessfrog
Copy link

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

@stockandawe
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants