Skip to content

fix(feed_routes): add input validation, config logging, and exception handling (M7)#6309

Open
waefrebeorn wants to merge 36 commits into
Scottcjn:mainfrom
waefrebeorn:fix-m7-feed-error-handling
Open

fix(feed_routes): add input validation, config logging, and exception handling (M7)#6309
waefrebeorn wants to merge 36 commits into
Scottcjn:mainfrom
waefrebeorn:fix-m7-feed-error-handling

Conversation

@waefrebeorn
Copy link
Copy Markdown

Summary

M7 — MED: bottube_feed_routes.py has 3 error handling gaps

Fix 1: _parse_feed_limit crashes on non-integer input

int(raw_limit) raised ValueError on ?limit=abc, crashing the endpoint with 500. Wrapped in try/except — returns default on invalid input.

  • Before: /api/feed?limit=abc → HTTP 500
  • After: /api/feed?limit=abc → uses default limit=20

Fix 2: _get_db_connection silent misconfiguration

Returns None when DB_PATH is not configured, causing silent fallback to mock data. Added logger.warning so operators can detect the issue.

Fix 3: feed_index route missing exception handling

rss_feed() and atom_feed() had outer try/except blocks, but the auto-detect feed_index() route only wrapped _parse_feed_limit_fetch_videos() could crash unhandled. Added proper try/except with logging and 500 response.

Testing

  • Syntax verified (Python AST parse)
  • All 3 fixes are defense-in-depth patterns already used elsewhere in the codebase
  • No behavioral change on valid input

RTC Wallet for bounty: RTC17c0d21f04f6f65c1a85c0aeb5d4a305d57531096

Adds max_length parameter to _clean_string_field and caps all user input
fields in POST route handlers:

- /lock: sender_wallet(128), target_wallet(128), tx_hash(128), receipt_signature(256)
- /confirm: proof_ref(256), notes(1024)
- /release: release_tx(128), notes(1024)

Prevents storage of arbitrarily large strings in bridge_ledger DB.
…s + Row M error handling + Row T test gaps + Row E infrastructure
…rawals (M6)

M6 - MED: payout_worker.py: cleanup_old_withdrawals file descriptor leak on archive

- Archive file now uses proper path (archives/ dir next to DB) instead of CWD-relative
- Uses .jsonl extension for append-log format
- f.flush() after each row ensures data is persisted before DB deletion
- OSError catch on file write prevents data loss: aborts without deleting DB
- Separate error handling for DB prune so inconsistency is logged but graceful
- Explicit column selection instead of SELECT * for maintainability
… handling (M7)

Three error handling gaps in bottube_feed_routes.py:

1. _parse_feed_limit: int(raw_limit) crashes with 500 on non-integer
   input like ?limit=abc. Wrapped in try/except ValueError/TypeError —
   returns default on invalid input.

2. _get_db_connection: returns None silently when DB_PATH is missing.
   Added logger.warning to make misconfiguration discoverable.

3. feed_index route: missing try/except around _fetch_videos() call.
   rss_feed and atom_feed endpoints were protected by their outer
   try/except blocks, but feed_index only wrapped _parse_feed_limit.
@github-actions github-actions Bot added documentation Improvements or additions to documentation BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related api API endpoint related size/L PR: 201-500 lines labels May 25, 2026
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.

LGTM! Great work on this PR. 🚀

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

Labels

api API endpoint related BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) documentation Improvements or additions to documentation node Node server related size/L PR: 201-500 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants