You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by ak...@apache.org on 2026/06/05 07:37:37 UTC
(tooling-gofannon) 13/25: stop passing kwargs the sync DatabaseService doesn't accept
This is an automated email from the ASF dual-hosted git repository.
andrewmusselman pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-gofannon.git
commit 97dfdab323fa6be90a32008be173069efb04f577
Author: Andrew Musselman <ak...@apache.org>
AuthorDate: Thu Jun 4 23:02:17 2026 +0000
stop passing kwargs the sync DatabaseService doesn't accept
Two signature mismatches in async_shim.py were causing TypeErrors at
runtime once the shimmed find() and ensure_index() were actually
exercised:
- find() enumerated a 'sort' kwarg the sync CouchDBService.find()
has never accepted, so the wrapper always passed sort=None and
the sync call exploded. Surfaced as 'CouchDBService.find() got
an unexpected keyword argument sort' on /data-store/namespaces.
- ensure_index() passed name= but the sync signature uses
index_name=. Would have surfaced the same way the moment any
caller exercised it.
Fix is the same shape for both: stop enumerating kwargs and pass
them through with **kwargs. The shim becomes a thin async facade
that doesn't need updating when sync method signatures evolve --
the sync class is the source of truth for what's accepted, and any
unsupported kwarg surfaces as a normal Python TypeError instead of
being silently dropped or quietly mistranslated by the shim.
---
.../services/database_service/async_shim.py | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/webapp/packages/api/user-service/services/database_service/async_shim.py b/webapp/packages/api/user-service/services/database_service/async_shim.py
index 9d8fcc2..8a6fabf 100644
--- a/webapp/packages/api/user-service/services/database_service/async_shim.py
+++ b/webapp/packages/api/user-service/services/database_service/async_shim.py
@@ -45,13 +45,14 @@ class AsyncDatabaseService:
self,
db_name: str,
selector: Dict[str, Any],
- limit: Optional[int] = None,
- fields: Optional[List[str]] = None,
- sort: Optional[List[Dict[str, Any]]] = None,
+ **kwargs,
) -> List[Dict[str, Any]]:
- return await asyncio.to_thread(
- self._sync.find, db_name, selector, limit=limit, fields=fields, sort=sort
- )
+ # kwargs passthrough so the shim doesn't need updating when the
+ # sync find() signature changes. Current sync signature accepts
+ # fields and limit; an earlier shim version enumerated a sort
+ # kwarg that the sync class never supported, which exploded the
+ # moment a real route exercised it.
+ return await asyncio.to_thread(self._sync.find, db_name, selector, **kwargs)
async def get_many(self, db_name: str, doc_ids: List[str]) -> List[Dict[str, Any]]:
return await asyncio.to_thread(self._sync.get_many, db_name, doc_ids)
@@ -70,8 +71,10 @@ class AsyncDatabaseService:
async def delete_many(self, db_name: str, doc_ids: List[str]):
return await asyncio.to_thread(self._sync.delete_many, db_name, doc_ids)
- async def ensure_index(self, db_name: str, fields: List[str], name: Optional[str] = None):
- return await asyncio.to_thread(self._sync.ensure_index, db_name, fields, name=name)
+ async def ensure_index(self, db_name: str, fields: List[str], **kwargs):
+ # Sync signature uses index_name (not name); pass-through avoids
+ # the naming mismatch.
+ return await asyncio.to_thread(self._sync.ensure_index, db_name, fields, **kwargs)
# --- escape hatch ---
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org