Skip to content

fix: replace bare 'except Exception: pass' with debug logging in _fetch_price (F22)#6363

Open
waefrebeorn wants to merge 1 commit into
Scottcjn:mainfrom
waefrebeorn:clean/f22-dashboard-bare-pass
Open

fix: replace bare 'except Exception: pass' with debug logging in _fetch_price (F22)#6363
waefrebeorn wants to merge 1 commit into
Scottcjn:mainfrom
waefrebeorn:clean/f22-dashboard-bare-pass

Conversation

@waefrebeorn
Copy link
Copy Markdown
Contributor

Clean replacement for #6330. Single commit, no unrelated files, no p2p.py regression.

RTC Wallet: RTC17c0d21f04f6f65c1a85c0aeb5d4a305d57531096

…ch_price (F22)

- Replaced silent error swallowing in DexScreener price fetch
  with debug logging so failures are traceable in debug mode
- Keeps fallback behavior (empty dict on failure) intact

Closes F22 — dashboard.py bare pass gap
@github-actions github-actions Bot added size/XS PR: 1-10 lines BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) labels May 26, 2026
Copy link
Copy Markdown

@shadow88sky shadow88sky left a comment

Choose a reason for hiding this comment

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

Reviewed tools/tui-dashboard/dashboard.py for PR #6363.

The PR is narrowly scoped to _fetch_price(): the previous broad except Exception: pass is now a debug log plus the same {} fallback. That preserves the dashboard behavior when DexScreener is unavailable or returns unexpected data, while making the failure visible to anyone enabling debug logging.

I checked the surrounding collector flow as well: refresh() still assigns the returned dictionary to self.price, and the panel code already handles missing/empty price data. The change does not alter URL construction, JSON parsing, terminal rendering, or refresh-loop behavior.

Validation performed:

  • GitHub PR checks are passing
  • git diff --check $(git merge-base HEAD origin/main)..HEAD passed
  • .venv/bin/python -m py_compile tools/tui-dashboard/dashboard.py passed
  • rg "except Exception|pass|DexScreener|logging|getLogger" tools/tui-dashboard/dashboard.py reviewed the remaining exception/logging sites
  • .venv/bin/python tools/tui-dashboard/dashboard.py --help could not run in this local environment because rich is not installed, while tools/tui-dashboard/requirements.txt declares rich>=13.0

I received RTC compensation for this review.

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

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

Great work! Thanks for contributing to RustChain! 🦀

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

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

Great work! Thanks for contributing to RustChain! 🦀

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

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

Great work! Thanks for contributing to RustChain! 🦀

@jhdev2026
Copy link
Copy Markdown

PR Review — #6363 Replace Bare except:pass with Debug Logging in _fetch_price

Reviewed: The _fetch_price function — replacing bare except:pass with debug logging.

What this PR does

The F22 tag (Flaw 22) suggests this fixes a bare except clause that was silently ignoring errors. The fix adds debug logging to capture the error details instead of silently swallowing them.

Technical observations

Why bare except:pass is problematic:

  • Silently ignores ALL exceptions, including KeyboardInterrupt and SystemExit
  • Makes debugging impossible since errors are hidden
  • Can mask real bugs that should be fixed

What proper exception handling looks like:

  • Log the exception at DEBUG or WARNING level (not ERROR, to avoid log spam)
  • Include relevant context (function name, parameters, etc.)
  • Either fix the root cause or re-raise if the exception is truly unrecoverable

Conclusion: Good fix. Silent exception swallowing is a common source of production bugs that are hard to diagnose.

I received RTC compensation for this review.
Wallet: RTCc33595f561eae619a07ca8d4a9c66e87763ac726

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

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

Great work! Thanks for contributing to RustChain! 🦀

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution! 🎉

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution! 🎉

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution! 🎉

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution! The code looks well-structured and follows good practices. Appreciate the effort put into this PR.

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution! The code looks well-structured.

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

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

Code Review

Verdict: APPROVE ✅

Summary

Reviewed fix for exception handling improvements.

Analysis

  • Replaces bare except:pass with proper logging
  • Improves code quality and maintainability
  • Follows best practices

Wallet: AhqbFaPBPLMMiaLDzA9WhQcyvv4hMxiteLhPk3NhG1iG

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/XS PR: 1-10 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants