-
Notifications
You must be signed in to change notification settings - Fork 131
fix(rivetkit): fix zod not validating body if content-type header not provided #3456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(rivetkit): fix zod not validating body if content-type header not provided #3456
Conversation
|
Deployment failed with the following error: Learn More: https://vercel.com/docs/limits#rate-limits |
Code ReviewSummaryThis PR introduces a Positive Aspects ✅
Regarding the PR TitleThe PR title mentions "fix zod not validating body if content-type header not provided", but I do not see evidence in the diff that this change directly addresses that issue. The refactoring extracts inline code into a helper function but does not appear to change validation behavior. Questions:
Minor Suggestions 💡
Files Changed
Overall AssessmentThis is a solid refactoring that improves code quality. However, clarification is needed on whether this actually fixes a validation bug or is purely a refactoring. If it is a bug fix, additional context and tests would strengthen the PR. Status: Approve pending clarification on the bug fix claim in the title. |
6667afc to
6cb921c
Compare
89cf636 to
5fa1ff1
Compare
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
Code ReviewSummaryThis PR fixes a bug where Zod validation wasn't working when the Positive Feedback ✅Code Quality
Bug Fix
Code Reduction
Suggestions for Improvement 💡1. Test Coverage
Example test location: 2. Documentation 3. Completeness Check 4. Commit Message Security Considerations 🔒No security concerns identified. The change actually improves security by ensuring validation runs consistently. Performance Considerations ⚡No performance impact - this is purely a refactoring that maintains the same OpenAPI spec structure. Final VerdictApprove with minor suggestions ✅ This is a solid bug fix with good code quality. The only missing piece is test coverage to prevent regression. The refactoring improves maintainability and follows established patterns in the codebase. Action Items:
Great work on identifying and fixing this validation issue! |
Code ReviewSummaryThis PR extracts the request body definition into a reusable helper function buildOpenApiRequestBody and adds the required: true property, which should fix the issue where Zod validation wasn't occurring when the Content-Type header wasn't provided. Positive Aspects
Potential Issues & Questions
Recommendations
Code Quality: 8/10The refactoring itself is clean and well-structured. The main concerns are around testing and documentation rather than the implementation itself. Verdict: Approve pending tests and documentation improvements. The code change is correct, but needs test coverage to prevent regressions. |
6cb921c to
b49dcfa
Compare
5fa1ff1 to
7a00c89
Compare
513dcb4 to
0449f4b
Compare
51383ee to
049afaa
Compare
|
Deployment failed with the following error: Learn More: https://vercel.com/docs/limits#rate-limits |
Pull Request ReviewSummaryThis PR refactors inline OpenAPI request body definitions into a reusable Code Quality ✅Strengths:
Architecture & Design ✅The new
Potential Issues & Considerations
Security ✅No security concerns identified. The change maintains the same validation behavior (or improves it if Performance ✅No performance impact. The helper function is called at route definition time, not at request time. Best PracticesSuggestions for improvement:
Verdict: ✅ Approve with minor suggestionsThis is a clean refactor that improves code maintainability. The main concern is ensuring there's test coverage for the specific bug mentioned in the PR title. Otherwise, the code looks good and follows TypeScript and project conventions well. 🤖 Generated with Claude Code |
Merge activity
|
0449f4b to
ec9ddfa
Compare
049afaa to
106b484
Compare
|
Code Review - PR #3456 Summary: This PR refactors request body definitions by extracting inline OpenAPI request body configuration into a reusable buildOpenApiRequestBody helper function to fix Zod validation when Content-Type header is not provided. Positive Aspects:
Key Finding: The required: true field was ADDED in this PR and was not present before. This is the actual bug fix! The previous inline definitions were missing this field, which likely caused @hono/zod-openapi to skip validation when Content-Type header was absent. Before: After: Suggestions for Improvement:
Security: No concerns. This actually improves security by ensuring validation runs consistently. Performance: No impact. Same OpenAPI specification structure. Files Changed:
Overall Assessment: Code Quality: 9/10 This is a solid bug fix disguised as a refactoring. The actual fix is adding required: true to the request body definition, which ensures Zod validation runs even without Content-Type headers. Verdict: Approve with Suggestions The code change is correct and improves the codebase. Primary recommendation is to add test coverage to verify the fix and prevent future regressions. Action Items:
Great catch on this validation issue! The fix is clean and well-implemented. |
PR Review: Fix Zod validation for request body without content-type headerSummaryThis PR addresses a bug where Zod schemas were not validating request bodies when the Content-Type header was not provided. The fix extracts the repeated OpenAPI request body configuration into a reusable helper function ✅ Positive Observations1. Good DRY (Don't Repeat Yourself) principle
2. Consistent with existing patterns
3. Correct fix for the validation issue
🔍 Observations & Suggestions1. Missing documentation on the actual bug
2. Incomplete refactoring
3. Consider adding explicit content-type validation // Example middleware (if not already present)
router.use('/actors', async (c, next) => {
const contentType = c.req.header('content-type');
if (c.req.method \!== 'GET' && (\!contentType || \!contentType.includes('application/json'))) {
return c.json({ error: 'Content-Type must be application/json' }, 415);
}
await next();
});4. Test coverage
5. Type safety for the helper function buildOpenApiRequestBody<T extends z.ZodType>(schema: T) {
// ...
}🔐 Security Considerations✅ No security concerns identified. The fix actually improves security by ensuring request validation happens consistently. ⚡ Performance Considerations✅ No performance impact. This is a build-time schema definition, not a runtime change. 📝 Code Style✅ Follows TypeScript/RivetKit conventions 🎯 RecommendationApprove with suggestions This is a solid bug fix that improves code quality through better abstraction. The main improvements would be:
Overall: Good work on identifying and fixing this validation issue! The refactoring makes the code cleaner and more maintainable. 🚀 |
106b484 to
18c686e
Compare
ec9ddfa to
3c2f399
Compare
Final Code Review SummaryThis PR introduces a Strengths
Code Quality AssessmentScore: 9/10 The refactoring itself is solid and follows established patterns in the codebase. The implementation is clean, reduces code duplication (net -1 line while improving maintainability), and makes future endpoint additions simpler and less error-prone. Suggestions for Improvement1. Clarify the Bug Fix (Medium Priority)The PR title mentions "fix zod not validating body if content-type header not provided", but:
Questions:
Recommendation: Add a PR description explaining:
2. Test Coverage (Medium Priority)No tests are included to verify the fix. Consider adding test cases for:
Suggested location: 3. Type Safety Enhancement (Low Priority - Nice to Have)Consider adding a type constraint for better type safety: import type { z } from 'zod';
function buildOpenApiRequestBody<T extends z.ZodType>(schema: T) {
return {
required: true,
content: {
"application/json": {
schema,
},
},
};
}4. Documentation (Low Priority - Nice to Have)If this fixes a validation bug, add a comment to prevent future regressions: /**
* Creates an OpenAPI request body definition with JSON content type.
* Marks the body as required to ensure Zod validation runs even when
* the Content-Type header is not provided by the client.
*/
function buildOpenApiRequestBody<T>(schema: T) {
// ...
}Files Changed
Security & Performance
Action ItemsBefore merge:
After merge:
Verdict: LGTM with suggestionsThis is a solid refactoring that improves code quality and maintainability. If it also fixes a validation bug (as the title suggests), adding a clear explanation and test coverage would make this PR excellent. The code change itself is correct and ready to merge. Great work on maintaining consistency in the codebase! |

No description provided.