Skip to content

[Bug]: NeptuneAnalyticsAdapter.is_empty() awaits synchronous function #2081

@pinkgoldpeach

Description

@pinkgoldpeach

Bug Description

Hi,

In the NeptuneAnalyticsAdapter in is_empty() query_result = await self._client.query(query) is called. However, self._client is a langchain_aws.graphs.neptune_graph.NeptuneAnalyticsGraph and query is synchronous.

Hence, this will throw an error [ERROR] TypeError: object list can't be used in 'await' expression.

is_empty()is used in search() therefore search with NeptuneAnalytics is not working.

Steps to Reproduce

  1. Create a NeptuneAnalyticsGraph
  2. Populate it, e.g. with cognify
  3. Use search on the existing graph

Expected Behavior

That the synchronous function is not awaited and therefore is_empty() and search() run through without errors.

Actual Behavior

An error is thrown [ERROR] TypeError: object list can't be used in 'await' expression.

Environment

AWS Lambda with Python 3.13 and Langchain AWS

Logs/Error Messages

`[ERROR] TypeError: object list can't be used in 'await' expression
Traceback (most recent call last):
  File "/var/task/aws_lambda_powertools/logging/logger.py", line 548, in decorate
    return lambda_handler(event, context, *args, **kwargs)
  File "/var/task/lambda_function.py", line 221, in lambda_handler
    result = asyncio.run(MY_FUNCTION_NAME(query_text=query_text, top_k=5))
  File "/var/lang/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
  File "/var/lang/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
  File "/var/lang/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
    return future.result()
  File "/var/task/lambda_function.py", line 139, in MY_FUNCTION_NAME
    return await cognee.search(query_text=query_text, query_type=SearchType.GRAPH_COMPLETION, top_k=top_k)
  File "/var/task/cognee/api/v1/search/search.py", line 193, in search
    filtered_search_results = await search_function(
  File "/var/task/cognee/modules/search/methods/search.py", line 101, in search
    await no_access_control_search(
  File "/var/task/cognee/modules/search/methods/no_access_control_search.py", line 44, in no_access_control_search
    is_empty = await graph_engine.is_empty()
  File "/var/task/cognee/infrastructure/databases/hybrid/neptune_analytics/NeptuneAnalyticsAdapter.py", line 425, in is_empty
    query_result = await self._client.query(query)`

Additional Context

No response

Pre-submission Checklist

  • I have searched existing issues to ensure this bug hasn't been reported already
  • I have provided a clear and detailed description of the bug
  • I have included steps to reproduce the issue
  • I have included my environment details

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions