Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(api): properly dedup name list responses#4337

Open
MasterPtato wants to merge 1 commit intofix-ups-formalize-subjectsfrom
fix-api-properly-dedup-name-list
Open

fix(api): properly dedup name list responses#4337
MasterPtato wants to merge 1 commit intofix-ups-formalize-subjectsfrom
fix-api-properly-dedup-name-list

Conversation

@MasterPtato
Copy link
Contributor

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@MasterPtato
Copy link
Contributor Author

MasterPtato commented Mar 3, 2026

@railway-app
Copy link

railway-app bot commented Mar 3, 2026

🚅 Deployed to the rivet-pr-4337 environment in rivet-frontend

Service Status Web Updated (UTC)
frontend-inspector 😴 Sleeping (View Logs) Web Mar 3, 2026 at 12:19 am
website 😴 Sleeping (View Logs) Web Mar 3, 2026 at 12:17 am
frontend-cloud ❌ Build Failed (View Logs) Web Mar 3, 2026 at 12:10 am
mcp-hub ✅ Success (View Logs) Web Mar 3, 2026 at 12:09 am
ladle ❌ Build Failed (View Logs) Web Mar 3, 2026 at 12:07 am

@claude
Copy link

claude bot commented Mar 3, 2026

Code Review

Summary

The use of IndexMap/IndexSet for deduplication across datacenter fanouts is a good approach and correctly solves the core dedup problem. However, there are a few issues worth flagging.


Bug: Limit applied before sort in list_names.rs and runners.rs

engine/packages/api-public/src/actors/list_names.rs (lines 63-69)
engine/packages/api-public/src/runners.rs (lines 101-108)

In both files, .take(limit) is applied to the iterator before sorting. IndexMap iterates in insertion order (the order results arrived from the datacenter fanout). .take(limit) selects the first limit entries in that arbitrary insertion order, then sorts them. The result is a sorted subset of a non-deterministic slice — not the first limit items alphabetically.

For example, if DCs return names ["z", "a", "b", "c", "d"] and limit=3, you get ["a", "b", "z"] instead of ["a", "b", "c"]. This also breaks cursor-based pagination since the cursor will point to the wrong position in the full ordered set.

The pre-existing code had the correct order: sort then truncate. The fix should collect all deduplicated names, sort, then apply the limit. Same issue applies in runners.rs.


Potential regression: cursor filtering removed in list.rs actor_ids path

engine/packages/api-public/src/actors/list.rs (the actor_ids branch)

The manual cursor filtering was removed. And fetch_actors_by_ids always constructs its peer query with cursor: None hardcoded (utils.rs:90), so the cursor is never forwarded to the peer. Clients using actor_ids + cursor for pagination will silently receive incorrect results (the same first page on every call).

If cursor pagination is intentionally unsupported for the actor_ids path, returning an explicit error when both actor_ids and cursor are provided would be safer than silently ignoring it.


Minor: redundant actors.truncate(limit) in list.rs

After passing Some(limit) to fetch_actors_by_ids, the result is still truncated to limit again (line 122). fetch_actors_by_ids sorts but does not truncate, and with multiple DCs each returning up to limit results the aggregated count can exceed limit. The truncate is correct and necessary — just worth a clarifying comment since it looks redundant at first glance.


@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 3, 2026

More templates

@rivetkit/cloudflare-workers

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/cloudflare-workers@4337

@rivetkit/framework-base

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/framework-base@4337

@rivetkit/next-js

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/next-js@4337

@rivetkit/react

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/react@4337

rivetkit

pnpm add https://pkg.pr.new/rivet-dev/rivet/rivetkit@4337

@rivetkit/sql-loader

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sql-loader@4337

@rivetkit/sqlite-vfs

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sqlite-vfs@4337

@rivetkit/traces

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/traces@4337

@rivetkit/workflow-engine

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/workflow-engine@4337

@rivetkit/virtual-websocket

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/virtual-websocket@4337

@rivetkit/engine-runner

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner@4337

@rivetkit/engine-runner-protocol

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner-protocol@4337

commit: d88911e

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant