fix(server): routing skips callable/actionable procedures #1551
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughReplace raw typeof/null runtime guards with ChangesRouter Traversal Callable Procedure Fix
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
|
If you have time, could you please review this PR? @rwyde |
There was a problem hiding this comment.
Code Review
This pull request enables support for callable procedures by replacing restrictive typeof object checks with isTypescriptObject in router-utils.ts, allowing functions to be treated as routers. It also adds a corresponding test case. Feedback highlights a copy-paste error in the new test's metadata and identifies several other functions within the same file that require similar updates to ensure consistent behavior across the library.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
More templates
@orpc/ai-sdk
@orpc/arktype
@orpc/client
@orpc/contract
@orpc/experimental-durable-iterator
@orpc/hey-api
@orpc/interop
@orpc/json-schema
@orpc/nest
@orpc/openapi
@orpc/openapi-client
@orpc/otel
@orpc/experimental-pino
@orpc/experimental-publisher
@orpc/experimental-publisher-durable-object
@orpc/experimental-ratelimit
@orpc/react
@orpc/react-query
@orpc/experimental-react-swr
@orpc/server
@orpc/shared
@orpc/solid-query
@orpc/standard-server
@orpc/standard-server-aws-lambda
@orpc/standard-server-fastify
@orpc/standard-server-fetch
@orpc/standard-server-node
@orpc/standard-server-peer
@orpc/svelte-query
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/vue-colada
@orpc/vue-query
@orpc/zod
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@packages/server/src/router-utils.test.ts`:
- Around line 185-187: The test fixture callablePong currently reuses
ping['~orpc'] verbatim, making the two fixtures identical; instead clone or
construct procedure-specific metadata for callablePong by copying ping['~orpc']
then modifying its identifying fields (e.g., procedure name/id or route) so
callablePong’s '~orpc' differs from ping['~orpc']; update the fixture assignment
for callablePong to use that modified metadata (referencing callablePong, ping,
and the '~orpc' property) so the test exercises a true difference.
🪄 Autofix (Beta)
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
Run ID: b9490138-5204-4dcd-b6e5-1a4ed719dd65
📒 Files selected for processing (2)
packages/server/src/router-utils.test.tspackages/server/src/router-utils.ts
There was a problem hiding this comment.
Pull request overview
Fixes a regression where router traversal (used by OpenAPI generation and request matching) skipped procedures that become function-valued after .callable() / .actionable().
Changes:
- Update router traversal logic to safely read hidden contracts only when the router value is a “TypeScript object” (object or function), allowing callable/actionable procedure proxies to be discovered.
- Update
getRouterto useisTypescriptObjectfor consistent traversal behavior with function-valued router nodes. - Add a unit test covering traversal of callable-style (function proxy) procedures.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/server/src/router-utils.ts | Adjusts router traversal/hidden-contract access to not skip function-valued procedures. |
| packages/server/src/router-utils.test.ts | Adds coverage for callable procedure proxies in traversal. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
lgtm. thank you :) |
Fixes #1545
Summary by CodeRabbit