Conversation
…ed solutions. * Optimalisation of over-engineered code, applied recommended alternatives.
|
Warning Review limit reached
Next review available in: 13 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughChangesVersion 4.2.20 metadata and Docker references were updated. The changes add API and input validation, configurable torrent limits, safer database handling, bounded announce responses, escaped JavaScript arguments, and shared compressed storage. Release and runtime changes
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant AnnounceHandler
participant Tracker
participant PeerStore
Client->>AnnounceHandler: announce with numwant
AnnounceHandler->>Tracker: validate and process announce
Tracker->>PeerStore: retrieve up to requested peer count
PeerStore-->>Tracker: peers
Tracker-->>AnnounceHandler: bounded response
AnnounceHandler-->>Client: encoded peers
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 7
🧹 Nitpick comments (1)
src/common/structs/compressed_bytes.rs (1)
48-48: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winDocument or hide the mutable tuple storage in
CompressedBytes.
CompressedBytesstores data aspub Arc<[u8]>, and the private impl only usescompress/decompress. Add an accessor method or keep the tuple field private, and update the docs to say the field is for crate-internal construction, becauseArcdoes not make the backing bytes immutable.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/common/structs/compressed_bytes.rs` at line 48, Update the CompressedBytes tuple struct to hide its Arc<[u8]> field or expose it through a deliberate accessor, and document that construction is intended for crate-internal use. Preserve the existing compress and decompress behavior while preventing callers from treating the public tuple storage as immutable merely because it uses Arc.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Line 603: Update the changelog entry containing “Optimalisation” to use
“Optimization,” preserving the rest of the release note unchanged.
In `@src/api/api_users.rs`:
- Around line 45-50: Validate and canonicalize the configured identifier in
user_removal_entry, then reuse that single validated value for both hashing and
UserEntryItem tombstone construction. In
src/database/impls/database_connector_mysql.rs:750-775,
src/database/impls/database_connector_pgsql.rs:758-783, and
src/database/impls/database_connector_sqlite.rs:774-799, update the user-removal
SQL paths to bind the resolved identifier parameter instead of interpolating
id_val, preserving the existing identifier semantics.
In `@src/config/impls/configuration.rs`:
- Around line 248-250: Update the TRACKER__MAX_TORRENTS override in the
configuration loading flow to preserve the already loaded
tracker_config.max_torrents value when parsing fails, rather than falling back
to 0; alternatively, reject the invalid override and fail startup. Keep valid
environment overrides unchanged.
In `@src/database/impls/database_connector_mysql.rs`:
- Around line 682-687: Update the user-loading pagination logic in
src/database/impls/database_connector_mysql.rs:682-687,
src/database/impls/database_connector_pgsql.rs:690-695, and
src/database/impls/database_connector_sqlite.rs:708-713 to track the number of
rows fetched from each page separately from successfully parsed users. Continue
fetching while the fetched-row count equals length, including when malformed
rows are skipped, rather than using the loaded-user count as the cursor
condition.
In `@src/tracker/impls/torrent_tracker_peers.rs`:
- Around line 60-75: Make torrent admission atomic with insertion: update
may_create_torrent and the vacant-entry insertion path to reserve capacity under
synchronization before creating a new torrent, preventing concurrent distinct
info-hashes from exceeding max_torrents. Release the reservation when insertion
does not complete or creation fails, while preserving max_torrents == 0 as
unlimited. Add a concurrent test covering distinct info-hashes and the
configured cap.
- Around line 248-255: Update the peer-removal flow before the completion
transition check in the tracker announce handling: remove the peer ID from both
IPv4 and IPv6 regular peer maps, regardless of the incoming address family, then
calculate `seeds_removed` and evaluate the `completed && torrent_peer.left ==
NumberOfBytes(0)` condition. Preserve the existing `was_rtc_seed` handling and
completion counter update.
In `@src/udp/impls/udp_server.rs`:
- Around line 588-593: Update the UDP response construction around the numwant
calculation to store the clamped value in a local variable, then reuse it for
response vector capacity and every subsequent seed and peer-loop limit instead
of the hard-coded 72. Preserve the existing 1..=72 clamping behavior, including
tracker-choice and out-of-range requests.
---
Nitpick comments:
In `@src/common/structs/compressed_bytes.rs`:
- Line 48: Update the CompressedBytes tuple struct to hide its Arc<[u8]> field
or expose it through a deliberate accessor, and document that construction is
intended for crate-internal use. Preserve the existing compress and decompress
behavior while preventing callers from treating the public tuple storage as
immutable merely because it uses Arc.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: be55612c-275d-4631-a0fb-90b681ac15e7
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (25)
Cargo.tomlREADME.mddocker/Dockerfiledocker/build.batsrc/api/api.rssrc/api/api_users.rssrc/common/impls/compressed_bytes.rssrc/common/structs/compressed_bytes.rssrc/config/config.rssrc/config/impls/configuration.rssrc/config/structs/tracker_config.rssrc/database/impls/database_connector_mysql.rssrc/database/impls/database_connector_pgsql.rssrc/database/impls/database_connector_sqlite.rssrc/http/http.rssrc/rtctorrent_bridge/impls/rtc_torrent_bridge.rssrc/security/security.rssrc/security/tests.rssrc/tracker/impls/torrent_tracker_handlers.rssrc/tracker/impls/torrent_tracker_peers.rssrc/tracker/mod.rssrc/tracker/tests.rssrc/udp/impls/parse_pool.rssrc/udp/impls/udp_server.rssrc/websocket/websocket.rs
… some recommended changes.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/database/impls/database_connector_pgsql.rs (1)
762-797: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick winBind UUID values for all user persistence statements. Both connectors bind UUIDs for DELETE statements but interpolate them into INSERT and UPDATE statements. A malformed UUID retained from a persisted row can break a save batch or change the generated SQL.
src/database/impls/database_connector_pgsql.rs#L762-L797: use a PostgreSQL placeholder and bind the UUID in the Add and Update paths.src/database/impls/database_connector_sqlite.rs#L778-L812: use a SQLite placeholder and bind the UUID in the Add and Update paths.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/database/impls/database_connector_pgsql.rs` around lines 762 - 797, Bind UUID values in all user persistence statements: in src/database/impls/database_connector_pgsql.rs lines 762-797, update the Add and Update paths to use PostgreSQL placeholders and bind the UUID through the query statement, matching the existing DELETE handling; in src/database/impls/database_connector_sqlite.rs lines 778-812, make the equivalent Add and Update changes using SQLite placeholders. Preserve numeric ID handling and existing control flow.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/tracker/impls/torrent_tracker_peers.rs`:
- Around line 180-185: Change the admission flow around try_claim_torrent_slot
and handle_announce to return an explicit rejected result instead of
AnnounceEntry::default(). Ensure rejected announces bypass persistence, cache,
and user activity/completion updates in torrent_tracker_handlers, while
preserving normal processing for admitted announces. Add integration coverage
for rejected Started and Completed announces.
---
Outside diff comments:
In `@src/database/impls/database_connector_pgsql.rs`:
- Around line 762-797: Bind UUID values in all user persistence statements: in
src/database/impls/database_connector_pgsql.rs lines 762-797, update the Add and
Update paths to use PostgreSQL placeholders and bind the UUID through the query
statement, matching the existing DELETE handling; in
src/database/impls/database_connector_sqlite.rs lines 778-812, make the
equivalent Add and Update changes using SQLite placeholders. Preserve numeric ID
handling and existing control flow.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: b4c68a81-bbaf-4977-8c66-c285538f4d29
📒 Files selected for processing (10)
README.mdsrc/api/api_users.rssrc/common/structs/compressed_bytes.rssrc/config/impls/configuration.rssrc/database/impls/database_connector_mysql.rssrc/database/impls/database_connector_pgsql.rssrc/database/impls/database_connector_sqlite.rssrc/tracker/impls/torrent_tracker_peers.rssrc/tracker/tests.rssrc/udp/impls/udp_server.rs
🚧 Files skipped from review as they are similar to previous changes (5)
- README.md
- src/common/structs/compressed_bytes.rs
- src/api/api_users.rs
- src/config/impls/configuration.rs
- src/database/impls/database_connector_mysql.rs
Summary by CodeRabbit
0preserves unlimited behavior.