feat: implement explicit custom error messages for theme validation in Zod API schemas #5698#5760
Conversation
|
@Openops-CommitVerse is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
🚨 Hey @attardekhushi78-cpu, the CI Pipeline is failing on this PR and it has been marked as Please fix the issues before this can be reviewed. Here's how: 1. Run checks locally before pushing: npm run format:check # Check Prettier formatting
npm run lint # Run ESLint
npm run typecheck # TypeScript type check
npm run test # Run unit tests (Vitest)
npm run build # Verify production build passes2. Auto-fix common issues: npm run format # Auto-fix formatting with Prettier
npm run lint -- --fix # Auto-fix lint errors where possible3. Check the full failure log here: Once you push a fix and the CI passes, the |
Aamod-Dev
left a comment
There was a problem hiding this comment.
Thanks for tightening the streak-parameter validation. I reviewed the PR description, linked issue #5698, the failing CI log, and the actual diff before labeling.
Labels applied:
level:intermediate: this is a single-file change inlib/validations.ts, but it touches the corebaseStreakParamsSchemapath fortheme,bg,text, andaccentand affects several downstream tests and API behaviors in one go.type:bug: the PR is explicitly fixing validation behavior, and the current failure is a behavioral regression in the streak route tests.
I am requesting changes because the new .refine() checks change invalid color inputs from graceful fallback to hard validation failures, and the existing streak route tests still expect 200 responses for those cases.
What is failing:
app/api/streak/route.test.tsnow receives400for invalidbg,text, andaccentinputs, but the tests still expect200.- The theme validation message was also changed from
Invalid theme. Supported themes:toInvalid theme selection. Supported themes:, so the expectations inlib/validations.test.ts,lib/validations.streakParamsSchema.test.ts, andlib/validations.theme-contrast.test.tsno longer match.
How to fix it:
- Decide whether the new behavior should be a hard validation error or a graceful fallback.
- If hard errors are intended, update the affected tests to expect
400and assert the new error messages. - If graceful fallback is intended, keep the new error messages for developer clarity, but move the invalid-color handling back into the transforms so the API still returns
200with sanitized defaults. - Re-run the streak and validations test files after the behavior is aligned.
Once the schema behavior and the tests agree again, this can move forward cleanly.
Aamod-Dev
left a comment
There was a problem hiding this comment.
This is still blocked, so I can’t approve it yet. The new .refine() checks in lib/validations.ts are a meaningful DX improvement, but the PR needs the failing checks cleared and the updated validation behavior verified end-to-end before we move it forward.
Aamod-Dev
left a comment
There was a problem hiding this comment.
I like the clearer validation messages, but the PR is still blocked and needs a clean pass after the schema changes. Please clear the blocker and add a focused test showing lib/validations.ts returns the new theme/background errors without breaking the existing fallback behavior.
Aamod-Dev
left a comment
There was a problem hiding this comment.
Review
This PR cannot be approved in its current state due to blocking issues (status:blocked label, merge conflicts, needs-rebase label, and/or failing CI checks). Please resolve the blocking issues and re-request review.
Once unblocked, I'm happy to re-review! 💚
Aamod-Dev
left a comment
There was a problem hiding this comment.
Improving the API Developer Experience with explicit Zod validation messages is a very good refactor. It makes debugging parameter errors much easier. However, the PR is marked as blocked. Please resolve the blocking issues so we can get this merged!
💡 Related Issue
Closes #5698
📝 Description
Refactored the underlying Zod validation parameters within
baseStreakParamsSchema(theme,bg,text, andaccent) to improve backend API Developer Experience (DX).Previously, when users passed invalid theme selections or malformed/incorrect hex codes, the schemas utilized immediate
.transform()blocks to silently fall back toundefinedor general structures. This behavior could obscure debugging info or trigger misleading errors further downstream.🛠️ Changes Implemented
.refine()validation blocks totheme,bg,text, andaccentfields insidelib/validations.tsprior to their transformations."Invalid background hex color format. Expected a valid 3, 4, 6, or 8-digit hex string.")..transform()structures to maintain backward compatibility with existing tests and rendering handlers.🧪 How This Was Tested
npm run dev).?bg=invalidHexValue).