Skip to content

Fix database health check endpoint#142

Open
BeauDevCode wants to merge 3 commits into
Xarlos89:masterfrom
BeauDevCode:bugfix/health-check-db-endpoint-135
Open

Fix database health check endpoint#142
BeauDevCode wants to merge 3 commits into
Xarlos89:masterfrom
BeauDevCode:bugfix/health-check-db-endpoint-135

Conversation

@BeauDevCode

Copy link
Copy Markdown

Summary:

  • Updates the bot health_check helper to call /hc_db for the database status instead of calling /hc_api twice.
  • Adds a focused unittest that verifies the helper requests /hc_api and /hc_db in order.
  • Corrects the issue where the >hc command could report API health for both API and DB fields.

Validation:

  • python -m unittest tests.test_api_helper -v
  • Result: 1 test passed
  • python -m unittest discover -s tests -v
  • Result: 1 test passed
  • python -m compileall -q src\bot\core\api_helper.py tests\test_api_helper.py
  • Result: passed
  • python -m ruff check src\bot\core\api_helper.py tests\test_api_helper.py
  • Result: not run locally because ruff is not installed in this environment

Related issue:

Risk:

  • Low
  • The change only updates the database health endpoint URL and adds isolated test coverage.

@Xarlos89 Xarlos89 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall a solid PR. Small catch in the tests. Good start to testing, covering the happy path. Error cases would be a nice next move.
Come join us in the discord server!

Comment thread tests/test_api_helper.py Outdated


class FakeSession:
calls = []

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially could bleed across test state. Could be handled better by moving it to an instance attribute.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks.

You're right that using a class attribute for calls could leak state across test instances. I've updated the test helper to store calls as an instance attribute instead.

I agree that additional error-path coverage would be valuable as a follow-up. For this PR I focused on validating the endpoint selection logic that fixes #135.

Also, thanks for the Discord invite. Do you have a link you can share?

Thanks for the review.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BeauDevCode

Copy link
Copy Markdown
Author

Follow-up verification:

  • FakeSession now stores request calls on self.calls, so the helper no longer shares call state across test instances.
  • The test asserts calls to http://eos.test/hc_api and http://eos.test/hc_db in order.
  • python -m unittest tests.test_api_helper -v passed locally.
  • python -m unittest discover -s tests -v passed locally.

@BeauDevCode BeauDevCode marked this pull request as ready for review June 9, 2026 04:42
@Xarlos89

Copy link
Copy Markdown
Owner

Hey @BeauDevCode Looks like pre-commit checks are failing. Could you update your PR with the fixes from there?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Health check always reports API status for DB — /hc_api called twice in api_helper

2 participants