Skip to content

fix(server): routing skips callable/actionable procedures #1551

Merged
dinwwwh merged 11 commits into
middleapi:mainfrom
dinwwwh:dinwwwh/issue1545
May 12, 2026
Merged

fix(server): routing skips callable/actionable procedures #1551
dinwwwh merged 11 commits into
middleapi:mainfrom
dinwwwh:dinwwwh/issue1545

Conversation

@dinwwwh
Copy link
Copy Markdown
Member

@dinwwwh dinwwwh commented May 12, 2026

Fixes #1545

Summary by CodeRabbit

  • Tests
    • Added test coverage verifying traversal correctly finds callable procedures augmented with metadata, including nested paths.
  • Refactor
    • Improved router-node validation during traversal to use a stricter object check while preserving traversal behavior into nested routes.

Review Change Stack

@dinwwwh dinwwwh requested a review from Copilot May 12, 2026 02:39
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label May 12, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9d85031f-e641-43e6-8eb9-a94f5e1c018c

📥 Commits

Reviewing files that changed from the base of the PR and between 303ac41 and 8e508f4.

📒 Files selected for processing (1)
  • packages/server/src/router-utils.test.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/server/src/router-utils.test.ts

📝 Walkthrough

Walkthrough

Replace raw typeof/null runtime guards with isTypescriptObject checks in router traversal and add a test verifying that function-valued procedures carrying ~orpc metadata are discovered at their router paths.

Changes

Router Traversal Callable Procedure Fix

Layer / File(s) Summary
Type guard refactor and traversal test
packages/server/src/router-utils.ts, packages/server/src/router-utils.test.ts
Import isTypescriptObject and use it to guard router traversal (getRouter), compute hiddenContract only when options.router is a TypeScript object, and add a test that constructs callable procedures with ~orpc metadata and asserts traversal invokes the callback for those procedures at ['ping'] and ['nested','pong'].

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • middleapi/orpc#1522: Modifies traverseContractProcedures and related guards; addresses similar traversal/guard issues.

Suggested labels

javascript, size:M

"I hop through router paths tonight, 🐇
Finding callables in the moonlight bright.
~orpc tucked on functions small,
Now traversal hears each rabbit's call.
Tests cheer, and everything is right."

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(server): routing skips callable/actionable procedures' accurately describes the main change - fixing a regression where callable/actionable procedures are skipped during routing traversal.
Linked Issues check ✅ Passed The PR addresses issue #1545 by modifying traversal logic to check isTypescriptObject before skipping function-valued procedures, allowing callable/actionable procedures to be properly recognized during router traversal.
Out of Scope Changes check ✅ Passed All changes directly address the regression: router-utils.ts refactors traversal guards to recognize function-valued procedures, and the test validates the fix handles callable procedures correctly.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dosubot dosubot Bot added the bug Something isn't working label May 12, 2026
@dinwwwh
Copy link
Copy Markdown
Member Author

dinwwwh commented May 12, 2026

If you have time, could you please review this PR? @rwyde

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot 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

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.

Comment thread packages/server/src/router-utils.ts
Comment thread packages/server/src/router-utils.test.ts Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 12, 2026

More templates

@orpc/ai-sdk

npm i https://pkg.pr.new/@orpc/ai-sdk@1551

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@1551

@orpc/client

npm i https://pkg.pr.new/@orpc/client@1551

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@1551

@orpc/experimental-durable-iterator

npm i https://pkg.pr.new/@orpc/experimental-durable-iterator@1551

@orpc/hey-api

npm i https://pkg.pr.new/@orpc/hey-api@1551

@orpc/interop

npm i https://pkg.pr.new/@orpc/interop@1551

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@1551

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@1551

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@1551

@orpc/openapi-client

npm i https://pkg.pr.new/@orpc/openapi-client@1551

@orpc/otel

npm i https://pkg.pr.new/@orpc/otel@1551

@orpc/experimental-pino

npm i https://pkg.pr.new/@orpc/experimental-pino@1551

@orpc/experimental-publisher

npm i https://pkg.pr.new/@orpc/experimental-publisher@1551

@orpc/experimental-publisher-durable-object

npm i https://pkg.pr.new/@orpc/experimental-publisher-durable-object@1551

@orpc/experimental-ratelimit

npm i https://pkg.pr.new/@orpc/experimental-ratelimit@1551

@orpc/react

npm i https://pkg.pr.new/@orpc/react@1551

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@1551

@orpc/experimental-react-swr

npm i https://pkg.pr.new/@orpc/experimental-react-swr@1551

@orpc/server

npm i https://pkg.pr.new/@orpc/server@1551

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@1551

@orpc/solid-query

npm i https://pkg.pr.new/@orpc/solid-query@1551

@orpc/standard-server

npm i https://pkg.pr.new/@orpc/standard-server@1551

@orpc/standard-server-aws-lambda

npm i https://pkg.pr.new/@orpc/standard-server-aws-lambda@1551

@orpc/standard-server-fastify

npm i https://pkg.pr.new/@orpc/standard-server-fastify@1551

@orpc/standard-server-fetch

npm i https://pkg.pr.new/@orpc/standard-server-fetch@1551

@orpc/standard-server-node

npm i https://pkg.pr.new/@orpc/standard-server-node@1551

@orpc/standard-server-peer

npm i https://pkg.pr.new/@orpc/standard-server-peer@1551

@orpc/svelte-query

npm i https://pkg.pr.new/@orpc/svelte-query@1551

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@1551

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@1551

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@1551

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@1551

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@1551

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@1551

commit: 71dd284

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0010bec and 303ac41.

📒 Files selected for processing (2)
  • packages/server/src/router-utils.test.ts
  • packages/server/src/router-utils.ts

Comment thread packages/server/src/router-utils.test.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 getRouter to use isTypescriptObject for 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.

Comment thread packages/server/src/router-utils.test.ts Outdated
Comment thread packages/server/src/router-utils.test.ts
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@dinwwwh dinwwwh merged commit 7605f6c into middleapi:main May 12, 2026
5 checks passed
@rwyde
Copy link
Copy Markdown

rwyde commented May 12, 2026

If you have time, could you please review this PR? @rwyde

lgtm. thank you :)

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

Labels

bug Something isn't working size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAPI traversal skips callable/actionable procedures

3 participants