ory / sdk

The place where ORY's SDKs are being auto-generated
Apache License 2.0
141 stars 85 forks source link

Python SDK: wrong write API URL for create_relation_tuple() #247

Closed jletroui closed 1 year ago

jletroui commented 1 year ago

Preflight checklist

Describe the bug

When calling WriteApi.create_relation_tuple(...), the HTTP call is returning 404 page not found.

The SDK is performing the call with the following url = 'http://localhost:4467/relation-tuples'.

The URL is wrong, it should be http://localhost:4467/admin/relation-tuples instead, as per the documentation.

Reproducing the bug

Steps to reproduce the error:

import ory_keto_client
from ory_keto_client.configuration import Configuration
from ory_keto_client.api import write_api
from ory_keto_client.model.relation_query import RelationQuery

configuration = Configuration()
configuration.host = 'http://localhost:4467'
client =  ory_keto_client.ApiClient(configuration)
write_api = write_api.WriteApi(client)
write_api.create_relation_tuple(relation_query=RelationQuery(
    subject_id='some-id',
    namespace='some-namespace',
    object='some-object',
    relation='some-relation'
))

Relevant log output

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "ory-keto-client\clients\keto\python\ory_keto_client\api\write_api.py", line 287, in create_relation_tuple
    return self.create_relation_tuple_endpoint.call_with_http_info(**kwargs)
  File "ory-keto-client\clients\keto\python\ory_keto_client\api_client.py", line 851, in call_with_http_info
    return self.api_client.call_api(
  File "ory-keto-client\clients\keto\python\ory_keto_client\api_client.py", line 410, in call_api
    return self.__call_api(resource_path, method,
  File "ory-keto-client\clients\keto\python\ory_keto_client\api_client.py", line 204, in __call_api
    raise e
  File "ory-keto-client\clients\keto\python\ory_keto_client\api_client.py", line 197, in __call_api
    response_data = self.request(
  File "ory-keto-client\clients\keto\python\ory_keto_client\api_client.py", line 464, in request
    return self.rest_client.PUT(url,
  File "ory-keto-client\clients\keto\python\ory_keto_client\rest.py", line 279, in PUT
    return self.request("PUT", url,
  File "ory-keto-client\clients\keto\python\ory_keto_client\rest.py", line 223, in request
    raise NotFoundException(http_resp=r)
ory_keto_client.exceptions.NotFoundException: (404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({'Content-Type': 'text/plain; charset=utf-8', 'X-Content-Type-Options': 'nosniff', 'Date': 'Tue, 17 Jan 2023 18:33:35 GMT', 'Content-Length': '19'})
HTTP response body: 404 page not found

Relevant configuration

namespaces:
  - id: 0
    name: "some-namespace"

Version

keto:v0.10.0-alpha.0

On which operating system are you observing this issue?

Windows

In which environment are you deploying?

Docker Compose

Additional Context

SDK version: v0.0.50

I did not check, but other URLs in the SDK might be wrong as well.

jonas-jonas commented 1 year ago

Thanks for the report!

Could you confirm the version of the SDK you're using?

The latest version of the ory_keto_client is 0.10.0a0. If you're not already on that version, could you check if the issue is still there in 0.10.0a0?

jletroui commented 1 year ago

Oops, sorry indeed, the problem is fixed. I installed the wrong version for the following reasons:

So I would suggest changing the above documentation to use the proper pypy package, instead of a git link, this would be a lot less confusing.

Thanks very much for the quick response!