Skip to content

Commit

Permalink
Fix auth validation with async client. (#135)
Browse files Browse the repository at this point in the history
* Fix now awaited coroutine

* fix

* Update CHANGELOG.md
  • Loading branch information
sunbit authored Dec 19, 2024
1 parent 2443a11 commit ee68924
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

## 4.4.2 (unreleased)


- Nothing changed yet.

- Fix auth validation with async client.

## 4.4.1 (2024-12-19)

Expand Down
4 changes: 2 additions & 2 deletions nuclia/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def get_client(kbid: str) -> NucliaDBClient:
return ndb


def get_async_client(kbid: str) -> AsyncNucliaDBClient:
async def get_async_client(kbid: str) -> AsyncNucliaDBClient:
auth = get_async_auth()
kb_obj = auth._config.get_kb(kbid)

Expand All @@ -96,7 +96,7 @@ def get_async_client(kbid: str) -> AsyncNucliaDBClient:
# OSS
ndb = AsyncNucliaDBClient(environment=Environment.OSS, url=kb_obj.url)
else:
if kb_obj.token is None and auth._validate_user_token():
if kb_obj.token is None and await auth._validate_user_token():
# User token auth
ndb = AsyncNucliaDBClient(
environment=Environment.CLOUD,
Expand Down
2 changes: 1 addition & 1 deletion nuclia/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def async_wrapper_checkout_kb(*args, **kwargs):
kbid = auth._config.get_default_kb()
if kbid is None:
raise NotDefinedDefault()
ndb = get_async_client(kbid)
ndb = await get_async_client(kbid)
elif url.find(BASE_DOMAIN) >= 0:
region = url.split(".")[0].split("/")[-1]
ndb = AsyncNucliaDBClient(
Expand Down
2 changes: 1 addition & 1 deletion nuclia/sdk/kb.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ async def copy(
remote_files[file_id] = file.value
else:
files_to_upload.append({"id": file_id, "data": file.value})
destination_kb = get_async_client(destination)
destination_kb = await get_async_client(destination)
failed = False
try:
uuid = await self.resource.create(ndb=destination_kb, **data)
Expand Down

0 comments on commit ee68924

Please sign in to comment.