Skip to content

fix: reject negative BoTTube feed limits#6339

Open
duongynhi000005-oss wants to merge 1 commit into
Scottcjn:mainfrom
duongynhi000005-oss:fix/bottube-negative-feed-limit
Open

fix: reject negative BoTTube feed limits#6339
duongynhi000005-oss wants to merge 1 commit into
Scottcjn:mainfrom
duongynhi000005-oss:fix/bottube-negative-feed-limit

Conversation

@duongynhi000005-oss
Copy link
Copy Markdown

Reject negative limit values for /api/feed, /api/feed/rss, and /api/feed/atom with HTTP 400 while preserving existing max-100 clamping for valid inputs.\n\nTests: PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python3 -m pytest tests/test_bottube_feed_routes.py -q

@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related tests Test suite changes labels May 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Welcome to RustChain! Thanks for your first pull request.

Before we review, please make sure:

  • Non-doc PRs have a BCOS-L1 or BCOS-L2 label
  • Doc-only PRs are exempt from BCOS tier labels when they only touch docs/**, *.md, or common image/PDF files
  • New code files include an SPDX license header
  • You've tested your changes against the live node

Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150)

A maintainer will review your PR soon. Thanks for contributing!

@github-actions github-actions Bot added the size/S PR: 11-50 lines label 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.

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 on this PR! The code looks clean and well-structured.

Review powered by RustChain Bounty Program

Wallet: AhqbFaPBPLMMiaLDzA9WhQcyvv4hMxiteLhPk3NhG1iG

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

@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 the negative-limit handling across the BoTTube feed routes.

Concrete observations:

  1. The parser-level change in node/bottube_feed_routes.py is well-scoped. _parse_feed_limit() still treats a missing or blank limit as the default, still clamps large positive values to maximum, and now rejects only values below zero before they reach _fetch_videos(). That keeps the existing limit=999 -> 100 behavior intact while preventing negative slicing/query limits from becoming surprising downstream behavior.

  2. The error propagation is already wired correctly for all three public feed variants: RSS and Atom return {"error": "Invalid parameter", "message": "limit must be non-negative"} through their existing except ValueError as e blocks, while /api/feed returns its existing Invalid limit parameter response. The PR does not need separate route-level branches for this case.

  3. The regression test is useful because it checks /api/feed/rss, /api/feed/atom, and /api/feed in one subTest loop, so the shared parser cannot be fixed for one endpoint and accidentally left untested on the others.

Small non-blocking suggestion: it may be worth adding limit=-999 or a whitespace-padded negative value in a future table-driven parser test, but Python int() already covers the whitespace case and the current route-level regression is enough for this fix.

Local validation:
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .venv/bin/python -m pytest tests/test_bottube_feed_routes.py -q -> 27 passed, 6 subtests passed.

Copy link
Copy Markdown
Contributor

@HuiNeng6 HuiNeng6 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: 1. Line 53-55: Good defensive check for negative limits. The ValueError prevents negative limits causing unexpected SQL queries. 2. Test coverage: The subTest loop covering RSS/Atom/api/feed ensures consistent fix. 3. Suggestion: Consider using a constant for the error message. Disclosure: I received RTC compensation for this review.

Copy link
Copy Markdown

@MolhamHamwi MolhamHamwi left a comment

Choose a reason for hiding this comment

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

Reviewed node/bottube_feed_routes.py and tests/test_bottube_feed_routes.py.

  1. _parse_feed_limit() now rejects negative values before the existing max(1, min(limit, maximum)) clamp, which closes the previous behavior where limit=-1 silently became 1 instead of surfacing invalid input to the route-level ValueError handling.
  2. The regression test covers all three feed entry points (/api/feed/rss, /api/feed/atom, and /api/feed), so the shared parser behavior is locked across RSS, Atom, and JSON responses rather than only one route.

Local validation: python3 -m pytest -q tests/test_bottube_feed_routes.py passed (27 passed).

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.

Code review completed. 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.

Code review completed. Thanks for contributing! 🚀

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! 🦀

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! 🦀

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) node Node server related size/S PR: 11-50 lines tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants