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

client.data.checker() returns a function instead of a boolean #63

Open
dandv opened this issue Jun 2, 2023 · 1 comment
Open

client.data.checker() returns a function instead of a boolean #63

dandv opened this issue Jun 2, 2023 · 1 comment

Comments

@dandv
Copy link
Contributor

dandv commented Jun 2, 2023

const client = weaviate.client({
  scheme: 'https',
  host: 'edu-demo.weaviate.network',
  apiKey: new weaviate.ApiKey('learn-weaviate'),
});

const id = '00ff6900-e64f-5d94-90db-c8cfa3fc851b';

result = await client.data
  .checker()
  .withClassName('JeopardyQuestion')
  .withId(id)
  .do();

console.log(typeof result, `result: ${result}`, JSON.stringify(result));

The output will be this,

function result: t=>{if(t.status>=400)return t.text().then(e=>{let r;try{r=JSON.stringify(JSON.parse(e))}catch{r=e}return Promise.reject(new Error(usage error (${t.status}): ${r}))});if(i)return t.json()} undefined

The object does exist,

result = await client.data
  .getterById()
  .withClassName('JeopardyQuestion')
  .withId(id)
  .do();

console.log(JSON.stringify(result, null, 2));

BTW the tests for checker() lack .withClassName(), which results in a warning, "Usage of objects paths without className is deprecated in Weaviate 1.19.6. Please provide className parameter".

@tsmith023
Copy link
Contributor

@dandv, this seems to be a multi-faceted issue. The core problem you're seeing is that the learn-weaviate API key in fact lacks the permissions necessary to use the .checker() method on the https://edu-demo.weaviate.network URL. This is because .checker() makes an HTTP HEAD request under-the-hood and this apparently requires elevated access.

You were unable to see this error in the client, however, due to the issue that you raised with regards to the return type in your MRE. A solution to this is open in a PR: #71, but the fundamental problem will remain: the demo API key cannot make HEAD requests so cannot use the .checker() method.

To see this for yourself, you can use POSTman or Insomnia to make a HEAD request to https://edu-demo.weaviate.network/v1/objects/WikiCity/00008ad0-f7f1-5fd8-8fd6-a03a203bd428 with an Authorization header of Bearer learn-weaviate and you will receive a 403 Forbidden error. On the other hand, if you remove this Authorization header entirely, you will receive a 401 Unauthorized header signifying that the API key is genuine but lacks the required permissions.

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

2 participants