fix: reject generated @All contracts - #684
Conversation
📝 WalkthroughWalkthrough
Changes
예상 코드 리뷰 노력🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 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 docstrings
🧪 Generate unit tests (beta)
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 |
📊 Benchmark Results❌ Some benchmarks failed
Updated: 2026-06-14T11:49:05.574Z · Commit: 3f96f19 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 @.changeset/codegen-all-routes.md:
- Line 6: The markdown file .changeset/codegen-all-routes.md is triggering a
markdownlint MD041 warning, which requires proper heading structure. Fix this by
either adding an appropriate heading (such as an H1 or H2) at the beginning or
before the content line that starts with "OpenAPI and RPC generators now reject
runtime-only", while maintaining the changeset format, or alternatively add a
linting configuration exception for this specific file to suppress the MD041
rule where the changeset structure does not allow for traditional markdown
headings.
In `@packages/openapi-spec/src/libs/emitOpenAPI.ts`:
- Around line 172-174: Both `packages/openapi-spec/src/libs/emitOpenAPI.ts`
(lines 172-174) and `packages/rpc-codegen/src/libs/generate.ts` (lines 37-39)
are throwing generic Error instances for `@All` route rejection instead of
Problem subclasses. Replace both generic Error throws with an appropriate
Problem subclass (following RFC 7807 Problem-based error handling) to maintain
consistent error handling across the generators. Use the same Problem subclass
in both locations to ensure uniform error contract compliance.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 23efd627-be1d-4d07-a795-e6cc2295d98c
📒 Files selected for processing (6)
.changeset/codegen-all-routes.mdpackages/openapi-spec/src/libs/emitOpenAPI.tspackages/openapi-spec/src/tests/emitOpenAPI.spec.tspackages/rpc-codegen/src/libs/generate.tspackages/rpc-codegen/src/tests/codegen.spec.tspackages/rpc-codegen/src/tests/e2e.spec.ts
Summary
OpenAPI and RPC generators now reject runtime-only
@Allroutes with clear route-specific diagnostics, so generated public contracts no longer fail generically or emit invalid client request methods.Fixes #668
변경 사항
@Allroutes that includes controller, method, and path context.method: 'ALL'is never emitted.@Allcontroller and RPC coverage for both direct RouteIR generation and extracted controller metadata.@croco/openapi-specand@croco/rpc-codegen.Verification
ALLroutes were accepted and generated.pnpm --filter @croco/openapi-spec exec vitest run src/tests/emitOpenAPI.spec.ts -t "@All"pnpm --filter @croco/rpc-codegen exec vitest run src/tests/codegen.spec.ts -t "ALL routes"pnpm --filter @croco/rpc-codegen exec vitest run src/tests/e2e.spec.ts -t "@All"pnpm test --filter=@croco/openapi-specpnpm test --filter=@croco/rpc-codegenpnpm typecheck --filter=@croco/openapi-spec --filter=@croco/rpc-codegenpnpm build --filter=@croco/openapi-spec --filter=@croco/rpc-codegenpnpm --filter @croco/openapi-spec lintpnpm --filter @croco/rpc-codegen lintpnpm checkpnpm typecheckpnpm testpnpm buildoxfmt,oxlintauto-changeset,test,typecheckSelf-review
@Allbefore producing invalid OpenAPI/RPC output, and tests cover both generators plus extracted RPC route metadata.@Allbehavior is untouched; the public generator behavior changes only for routes that could not be represented as concrete generated contracts.Risk
Users with
@Allroutes in generated-contract inputs must replace them with explicit concrete HTTP method decorators for OpenAPI/RPC generation.Summary by CodeRabbit
릴리스 노트
버그 수정
@All라우트를 명확한 진단 메시지로 거부하도록 개선되었습니다.테스트
@All라우트 거부 동작에 대한 테스트 케이스가 추가되었습니다.