Skip to content

fix(rivetkit): route raw request fetches to actors#4781

Draft
NathanFlurry wants to merge 1 commit intodriver-fixes/db-migrate-before-lifecyclefrom
driver-fixes/raw-request-routing
Draft

fix(rivetkit): route raw request fetches to actors#4781
NathanFlurry wants to merge 1 commit intodriver-fixes/db-migrate-before-lifecyclefrom
driver-fixes/raw-request-routing

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member Author

NathanFlurry commented Apr 26, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown

claude Bot commented Apr 26, 2026

Review: fix(rivetkit): route raw request fetches to actors

This is a clean, focused fix that correctly bypasses framework routing for raw actor /request paths.

What the change does

handle_fetch previously always called framework_http_route on every incoming path. For raw actor requests (paths under /request), this was incorrect — they should be dispatched directly to the actor's onRequest handler, not routed through the framework layer. The fix adds an early is_actor_request_path check and short-circuits framework_route to None for those paths.

Strengths

  • Logic is DRY and consistent. is_actor_request_path and normalize_actor_request_path use identical matching rules (strip_prefix("/request"), then check for empty / / / ?). The test directly validates this alignment, which is exactly the right property to assert.
  • Early check, correct placement. The is_actor_request_path call happens on request.path before build_http_request, avoiding touching the Uri layer unnecessarily.
  • /requestfoo edge case is handled. The function correctly rejects paths where /request is only a prefix of a longer path segment, which matches the normalization behavior.

Minor observations

Fragment-only suffixis_actor_request_path doesn't handle /request#section, but HTTP clients strip fragments before sending requests, so this is a non-issue in practice.

normalize_actor_request_path("/request?foo=bar") returns "?foo=bar" — this produces a query-string-only value as the path, which looks odd. This is pre-existing behavior and out of scope for this PR, but worth a follow-up to confirm Request::from_parts handles it correctly or that request.path never contains a query string in practice.

Inline test module — CLAUDE.md specifies Rust tests should live under tests/, with an exception for private internals (which applies here since both functions are private). Adding to the existing inline module is fine, but worth noting the CLAUDE.md shim pattern (#[cfg(test)] #[path = "..."] mod tests;) if these tests are ever migrated.

Empty PR description — worth adding one sentence explaining the bug (framework routing incorrectly intercepting /request paths) for the git history.

Overall

The fix is correct, minimal, and well-tested. No blockers.

@github-actions
Copy link
Copy Markdown
Contributor

Preview packages published to npm

Install with:

npm install rivetkit@pr-4781

All packages published as 0.0.0-pr.4781.1d1b363 with tag pr-4781.

Engine binary is shipped via @rivetkit/engine-cli on linux-x64-musl, linux-arm64-musl, darwin-x64, and darwin-arm64. Windows users should use the release installer or set RIVET_ENGINE_BINARY.

Docker images:

docker pull rivetdev/engine:slim-1d1b363
docker pull rivetdev/engine:full-1d1b363
Individual packages
npm install rivetkit@pr-4781
npm install @rivetkit/react@pr-4781
npm install @rivetkit/rivetkit-napi@pr-4781
npm install @rivetkit/workflow-engine@pr-4781

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