microsoft / microsoft/AzureTRE

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

Open Beginner friendly
#4,926 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
235
Forks
192
Avg merge
1d 23h
Merged PRs (30d)
13

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in api_app/services/health_checker.py and inspect the health-check path that calls container.query_items. Add or update a test that verifies the health check actually detects an inaccessible Cosmos container, then confirm the query is iterated and the test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, python
Domain
cloud, databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.