Skip to content

fix: hide dashboard health exception details#5443

Merged
Scottcjn merged 1 commit into
Scottcjn:mainfrom
hungle123-dev:codex/dashboard-health-generic-errors
May 18, 2026
Merged

fix: hide dashboard health exception details#5443
Scottcjn merged 1 commit into
Scottcjn:mainfrom
hungle123-dev:codex/dashboard-health-generic-errors

Conversation

@hungle123-dev
Copy link
Copy Markdown
Contributor

Fixes #5442.

Summary

  • Add health-check regression coverage for database, Solana RPC, and configured wRTC mint failures.
  • Log raw exceptions server-side with logger.exception(...).
  • Return generic component detail strings so /bridge/dashboard/health still reports degraded/offline status without leaking local paths, private RPC URLs, tokens, or internal exception text.

Root cause

The dashboard health endpoint converted caught exceptions directly into response details with str(e). That made diagnostic internals visible to API callers whenever database/RPC/mint checks failed.

Validation

  • RED first:
    • python -m pytest bridge/test_dashboard_api.py::TestBridgeHealth::test_health_hides_database_exception_details -q failed because the response leaked C:/srv/rustchain/private/bridge.db.
    • python -m pytest bridge/test_dashboard_api.py::TestBridgeHealth::test_health_hides_rpc_exception_details -q failed because the response leaked https://internal-solana.local/rpc?token=secret.
    • python -m pytest bridge/test_dashboard_api.py::TestBridgeHealth::test_health_hides_mint_exception_details -q failed because the response leaked the configured mint lookup exception.
  • Focused health suite: python -m pytest bridge/test_dashboard_api.py::TestBridgeHealth -q -> 7 passed.
  • Full dashboard suite: python -m pytest bridge/test_dashboard_api.py -q -> 25 passed.
  • Syntax check: python -m py_compile bridge\dashboard_api.py bridge\test_dashboard_api.py -> passed.
  • Whitespace: git diff --check -- bridge/dashboard_api.py bridge/test_dashboard_api.py -> passed.

@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/M PR: 51-200 lines labels May 16, 2026
Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Contributor

@kekehanshujun kekehanshujun left a comment

Choose a reason for hiding this comment

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

Approved. I reviewed the dashboard health exception redaction path and did not find a blocker.

What I checked:

  • bridge/dashboard_api.py now logs raw database, Solana RPC, and wRTC mint lookup exceptions server-side with logger.exception(...) instead of returning str(e) to clients.
  • The response shape still preserves per-component health/degraded state, but the client-facing detail strings are generic: Database unavailable, RPC unavailable, and Mint check unavailable.
  • The new tests inject exception messages containing internal paths, RPC URLs/tokens, and configured mint identifiers, then assert those values are absent from the API response.

Validation on head ffe0ff38f449df8003b5f59a0de115cdb98ac508:

  • $env:PYTHONPATH=.tmp-pr5443-files; python -m pytest .tmp-pr5443-files\bridge\test_dashboard_api.py::TestBridgeHealth -q --confcutdir=.tmp-pr5443-files -> 7 passed
  • $env:PYTHONPATH=.tmp-pr5443-files; python -m pytest .tmp-pr5443-files\bridge\test_dashboard_api.py -q --confcutdir=.tmp-pr5443-files -> 25 passed
  • python -m py_compile .tmp-pr5443-files\bridge\dashboard_api.py .tmp-pr5443-files\bridge\test_dashboard_api.py .tmp-pr5443-files\bridge\bridge_api.py -> passed

No blocking issue found in this scope.

Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for contributing!

Copy link
Copy Markdown

@ZacharyZhang-NY ZacharyZhang-NY left a comment

Choose a reason for hiding this comment

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

Reviewed PR #5443 at head ffe0ff3.

Validation performed:

  • git fetch origin pull/5443/head:review-pr-5443 --force
  • git diff --check origin/main...review-pr-5443 -- bridge/dashboard_api.py bridge/test_dashboard_api.py -> passed.
  • python -m py_compile bridge/dashboard_api.py bridge/test_dashboard_api.py bridge/bridge_api.py on an extracted PR-head tree -> passed.
  • python -m pytest bridge/test_dashboard_api.py::TestBridgeHealth -q --confcutdir= -> 7 passed.
  • python -m pytest bridge/test_dashboard_api.py -q --confcutdir= -> 25 passed.
  • Checked issue #5442, which scopes the leak to database, Solana RPC, and configured wRTC mint health-check exceptions in /bridge/dashboard/health.
  • Compared PR #5457, which is a parallel fix for the same issue.

The health endpoint still reports component status and generic detail strings, while raw database path/RPC URL/mint lookup exception text is logged server-side with logger.exception(...) instead of being returned to clients. This satisfies the issue-scoped redaction behavior; this branch overlaps PR #5457, so the maintainer can choose the preferred implementation.

Copy link
Copy Markdown

@TJCurnutte TJCurnutte left a comment

Choose a reason for hiding this comment

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

Scoped review on the dashboard health error redaction change looks good.

Validated head ffe0ff38f449df8003b5f59a0de115cdb98ac508 locally with:

git diff --check origin/main...HEAD -- bridge/dashboard_api.py bridge/test_dashboard_api.py
PYTHONPATH=. python3 -B -m py_compile bridge/dashboard_api.py bridge/test_dashboard_api.py
PYTHONPATH=. uv run --no-project --with pytest --with flask python -B -m pytest -q bridge/test_dashboard_api.py --noconftest

Result: 25 passed in 1.85s.

The patch keeps the health endpoint operational while moving raw DB/RPC/mint exception details out of the public JSON body. The new tests monkeypatch secret-bearing database and RPC failures, verify the endpoint reports generic Database unavailable, RPC unavailable, and Mint check unavailable messages, and assert those secret exception strings are absent from the response. Server-side detail is still retained through logger.exception, which is the right boundary.

I did not find a blocker in this scoped pass.

@BossChaos
Copy link
Copy Markdown
Contributor

Code Review — Bounty #73

PR: fix: hide dashboard health exception details by @hungle123-dev
Files changed: 2 (+73/-6)

  • ✅ Bug fix or input validation
  • ✅ Input validation present
  • ✅ Error handling present

Summary

This is a bug fix PR. Changes appear consistent with project patterns.

Wallet: 0xdaE5d307339074A24F579dB48e7c639359D94904

Reviewing under Bounty #73 — Code Review Bounty Program

Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM!

@Scottcjn Scottcjn merged commit f0eea00 into Scottcjn:main May 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/M PR: 51-200 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Dashboard health leaks internal component exception details

8 participants