Skip to content

Health check can falsely return OK even if Cosmos is down or inaccessible #4926

Description

@JC-wk

Describe the bug
in api_app/services/health_checker.py
container.query_items("SELECT TOP 1 * FROM c")

This does NOT execute the query.
query_items() returns an async iterable (AsyncItemPaged).
No iteration = no request sent to Cosmos DB.
This means the health check can falsely return OK even if Cosmos is down or inaccessible.

Should be:
async for _ in container.query_items("SELECT TOP 1 * FROM c", max_item_count=1): break

Steps to reproduce

  1. Write a test to check the health and see that it does not match

Azure TRE release version (e.g. v0.14.0 or main):
main

Deployed Azure TRE components - click the (i) in the UI:
latest

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions