Skip to content

fix: reject duplicate tRPC procedure names - #1760

Open
kang-heewon wants to merge 1 commit into
trunkfrom
fix/1678-reject-duplicate-trpc-procedures
Open

fix: reject duplicate tRPC procedure names#1760
kang-heewon wants to merge 1 commit into
trunkfrom
fix/1678-reject-duplicate-trpc-procedures

Conversation

@kang-heewon

@kang-heewon kang-heewon commented Aug 5, 2026

Copy link
Copy Markdown
Member

Outcome

Routes that resolve to the same tRPC domain and procedure name now fail during router construction instead of silently overwriting the earlier procedure. The stable configuration Problem identifies the collision key and both controller routes, including decorator source locations when available.

Unique procedures keep their existing query, mutation, schema, and execution behavior. The generated Problem registry marks the configuration failure as non-retryable, and patch changesets cover protocols-trpc and the generated problems-core code union.

Fixes #1678

Verification

  • pnpm --filter @croco/protocols-trpc test — 24 passed
  • pnpm --filter @croco/protocols-trpc typecheck — passed
  • pnpm --filter @croco/protocols-trpc lint — passed
  • pnpm --filter @croco/protocols-trpc build — passed
  • pnpm exec vitest run scripts/tests/problem-registry.spec.ts --config vitest.config.ts — 24 passed
  • pnpm problem-registry:check — 577/577 codes passed
  • pnpm public-api:check — 115/115 snapshots passed
  • pnpm package-manifests:check — 115 manifests passed
  • pnpm changeset-required:check -- --base origin/trunk --head HEAD — passed
  • pnpm check — 24/25 repository gates passed; 1 not applicable
  • pre-push workspace gates — 234/234 test tasks and 233/233 typecheck tasks passed

Review gates

  • Correctness and regression — PASS after independent review fix. Unit coverage asserts the stable Problem and exact route diagnostics; an unmocked decorator round trip proves both real source locations; the existing unique-route suite remains green.
  • API, security, compatibility, and release — PASS after changeset coverage fix. Public exports, manifests, dependencies, and lockfile are unchanged; Problem registry and recovery metadata are aligned; patch changesets cover both affected publishable packages.
  • Maintainability and minimality — PASS. Collision tracking reuses RouteIR source metadata and the established HTTP route diagnostic shape; generated changes are limited to required registry artifacts.
  • Independent adversarial review — PASS after adding the actual decorator-to-RouteIR source-location test; final re-review found no actionable findings.

Residual risk

None identified within the issue scope.

Summary by CodeRabbit

  • 새로운 기능

    • tRPC 라우터에서 중복된 프로시저 이름을 자동으로 감지합니다.
    • 오류 발생 시 충돌한 라우트의 컨트롤러, 메서드, HTTP 정보와 소스 위치를 함께 제공합니다.
    • 중복 프로시저 오류에 대한 문제 코드와 복구 지침을 등록했습니다.
  • 문서

    • 문제 레지스트리에 중복 프로시저 문제를 추가하고 관련 참조 정보를 갱신했습니다.
    • 지원되지 않음으로 분류되었던 텔레메트리 신호를 활성 상태로 변경했습니다.
  • 버그 수정

    • 중복 라우트 등록으로 인한 모호한 동작을 사전에 차단합니다.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ffeffca3-6609-4228-bb11-3313469db309

📥 Commits

Reviewing files that changed from the base of the PR and between 6795b4d and 9d9326a.

⛔ Files ignored due to path filters (1)
  • packages/problems-core/src/generated/problem-code-registry.ts is excluded by !**/generated/**
📒 Files selected for processing (7)
  • .changeset/fuzzy-pandas-warn.md
  • docs/problem-code-registry.json
  • packages/docs/src/content/docs/en/reference/problem-recovery-cookbook.md
  • packages/protocols-trpc/src/libs/createTrpcRouter.ts
  • packages/protocols-trpc/src/tests/createTrpcRouter.spec.ts
  • packages/protocols-trpc/src/tests/round-trip.spec.ts
  • scripts/problem-registry.mts

📝 Walkthrough

Walkthrough

라우터 생성 시 동일한 tRPC 도메인과 프로시저 이름의 중복 등록을 거부합니다. 오류는 기존 라우트와 충돌 라우트의 메타데이터와 소스 위치를 포함합니다. 문제 레지스트리, 복구 메타데이터, 테스트, changeset을 갱신합니다.

Changes

중복 tRPC 프로시저 처리

Layer / File(s) Summary
라우터 중복 검출 및 진단
packages/protocols-trpc/src/libs/createTrpcRouter.ts
도메인별 프로시저 이름을 추적합니다. 중복이 발견되면 기존 라우트와 충돌 라우트의 컨트롤러, 메서드, HTTP 정보, 소스 위치를 포함한 오류를 생성합니다.
중복 오류 검증
packages/protocols-trpc/src/tests/createTrpcRouter.spec.ts, packages/protocols-trpc/src/tests/round-trip.spec.ts
중복 등록 오류의 상태, 식별 정보, 라우트 메타데이터, 소스 위치, 상세 메시지를 검증합니다.
문제 레지스트리 및 릴리스 메타데이터
scripts/problem-registry.mts, docs/problem-code-registry.json, .changeset/fuzzy-pandas-warn.md
protocols-trpc/duplicate-procedure-name 코드와 복구 메타데이터를 등록합니다. 관련 소스 참조와 TELEMETRY_SIGNAL_UNSUPPORTED 상태를 갱신합니다. 두 패키지의 patch 릴리스를 기록합니다.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RouteIR
  participant createTrpcRouter
  participant TrpcDuplicateProcedureProblem
  RouteIR->>createTrpcRouter: 라우트 메타데이터 제공
  createTrpcRouter->>createTrpcRouter: 도메인별 프로시저 이름 추적
  createTrpcRouter->>TrpcDuplicateProcedureProblem: 중복 라우트 진단 정보 전달
  TrpcDuplicateProcedureProblem-->>createTrpcRouter: 중복 등록 오류 반환
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning TELEMETRY_SIGNAL_UNSUPPORTED의 deprecated 상태 제거와 active 전환은 연결된 이슈의 중복 프로시저 범위와 관련이 없습니다. TELEMETRY_SIGNAL_UNSUPPORTED 변경을 제거하거나, 해당 변경이 필요한 근거를 PR 범위와 문서에 명시하십시오.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 중복 tRPC 프로시저 이름을 거부하는 주요 변경 사항을 정확하고 간결하게 설명합니다.
Linked Issues check ✅ Passed 중복 등록 감지, 결정적 오류 발생, 양쪽 라우트 진단, 테스트 및 고유 프로시저 동작 보존 요구를 충족합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1678-reject-duplicate-trpc-procedures

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.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

📊 Benchmark Results

✅ All benchmarks passed

Benchmark p75 Threshold Baseline vs Baseline Status Notes
CrocoApp constructor 37.8μs 30.0ms 8.2μs +362.2% -
CrocoApp lambdaHandler (10 controllers) 1.9ms 50.0ms 258.4μs +625.8% -
Lambda cold-start simulation 1.7ms 80.0ms 418.1μs +307.6% -
Lambda cold-start with headers 1.5ms 80.0ms 369.7μs +302.3% -
Lambda cold-start with binary body 1.5ms 80.0ms 339.1μs +337.0% -
Lambda cold-start with query params 1.5ms 80.0ms 301.3μs +384.1% -
Lambda cold-start with authorizer context 1.4ms 80.0ms 299.8μs +380.5% -
Lambda cold-start realistic scenario 1.4ms 80.0ms 299.2μs +376.9% -
EventBusConfig.start (10 handlers) 1.9μs 10.0ms 1.4μs +34.9% -
EventPublisher.publishNow single event 2.2μs 2.0ms 1.7μs +31.0% -
DefaultHandlerResolver.resolve × 10 0.1μs 5.0ms 0.1μs +0.0% -
Container.get singleton (cold) 86.8μs 5.0ms 70.3μs +23.6% -
Container.register × 50 components 3.3ms 10.0ms 3.2ms +2.2% -
Container.validate (50 components) 3.7ms 20.0ms 3.4ms +7.9% -
Container.get singleton (warm) 1.7μs 500.0μs 1.6μs +1.2% -
TelemetryRuntime.init (lambda preset) 2.4μs 200.0ms 1.1ms -99.8% -
lambdaPreset config creation 1.5μs 2.0ms 1.4μs +2.2% -

Updated: 2026-08-08T07:30:37.100Z · Commit: fdf68c0

@kang-heewon
kang-heewon force-pushed the fix/1678-reject-duplicate-trpc-procedures branch from c7a3ec8 to 9d9326a Compare August 8, 2026 07:20
@kang-heewon

Copy link
Copy Markdown
Member Author

Current-head validate failed only at dependency-audit-policy because the newly published nanoid advisory GHSA-2v37-7h3g-55p8 produced six blocking findings. The failure reproduces on a clean archive of exact base 6795b4d, while this PR changes neither pnpm-lock.yaml nor dependency manifests. Tracked as base CI regression #1782: #1782. All other selected verification checks, the 207 passing Vitest evidence records, companion, benchmark, docs, and real-resource checks passed. This unrelated dependency-policy fix should not be folded into #1760.

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.

[protocols-trpc] Reject duplicate procedure names instead of overwriting routes

1 participant