fix(server): support Zod v4 in query parameter type detection#13963
fix(server): support Zod v4 in query parameter type detection#13963intojhanurag wants to merge 3 commits intomastra-ai:mainfrom
Conversation
Signed-off-by: intojhanurag <aojharaj2004@gmail.com>
🦋 Changeset detectedLatest commit: 3bb37d6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 21 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@intojhanurag is attempting to deploy a commit to the Mastra Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughNormalize Zod type inspection to support Zod v3 and v4, classify optional and complex types, and wrap detected complex query-parameter fields for JSON parsing to fix invalid query parameter errors for date ranges, tags, and metadata. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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 unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.changeset/fix-zod4-query-param-detection.md:
- Around line 5-7: Rewrite the changeset to describe the user-visible server
fix: explain that `@mastra/server` now correctly parses complex query parameters
(objects, arrays, records) when projects use Zod v4 so features like date-range
filters, tag filters and metadata filters in the server API/Studio work again;
remove internal implementation details about _def.typeName or _def.type and keep
the focus on the observable behavior change; ensure the frontmatter only
references `@mastra/server` and that the body is phrased for end users (what
changed and why it matters) rather than internal symbol names, but you can
mention wrapSchemaForQueryParams in a short note if needed to locate the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f1481887-2ca5-42bc-853c-f65b07cc5a04
📒 Files selected for processing (2)
.changeset/fix-zod4-query-param-detection.mdpackages/server/src/server/server-adapter/routes/route-builder.ts
Signed-off-by: intojhanurag <aojharaj2004@gmail.com>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
.changeset/fix-zod4-query-param-detection.md (1)
5-7:⚠️ Potential issue | 🟡 MinorRewrite this as a package-scoped release note.
This still reads like a commit title, and it mentions Studio even though the frontmatter only lists
@mastra/server. Keep the entry focused on the server behavior users get from this package.Suggested rewrite
-fix(server): fix complex query parameter parsing for Zod v4 projects - -Projects using Zod v4 would get "Invalid query parameters" errors when using date-range filters, tag filters, or metadata filters in the Studio Observability UI and server API. Complex query parameters (objects, arrays, records) are now correctly detected and parsed regardless of whether the project uses Zod v3 or v4. +Fixed complex query parameter parsing in `@mastra/server` for projects using Zod v4. + +Server routes now correctly parse JSON-encoded query parameters for objects, arrays, and records. This fixes requests that previously failed with invalid query parameter errors.potential_issue
As per coding guidelines, "Avoid commit messages, technical jargon, and acronyms" and "Check that the description inside the changeset file only applies to the packages listed in the frontmatter."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.changeset/fix-zod4-query-param-detection.md around lines 5 - 7, Rewrite the changeset entry so it is a package-scoped release note for `@mastra/server` (remove any mention of Studio and commit-style phrasing like "fix(...)"). Replace the title/body starting with "fix(server): fix complex query parameter parsing for Zod v4 projects" with a plain English release note that states the user-facing change: that `@mastra/server` now correctly detects and parses complex query parameters (objects, arrays, records) — including date-range, tag, and metadata filters — for projects using Zod v4, preventing "Invalid query parameters" errors; keep it concise and non-technical and ensure it only references the `@mastra/server` package listed in the frontmatter.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In @.changeset/fix-zod4-query-param-detection.md:
- Around line 5-7: Rewrite the changeset entry so it is a package-scoped release
note for `@mastra/server` (remove any mention of Studio and commit-style phrasing
like "fix(...)"). Replace the title/body starting with "fix(server): fix complex
query parameter parsing for Zod v4 projects" with a plain English release note
that states the user-facing change: that `@mastra/server` now correctly detects
and parses complex query parameters (objects, arrays, records) — including
date-range, tag, and metadata filters — for projects using Zod v4, preventing
"Invalid query parameters" errors; keep it concise and non-technical and ensure
it only references the `@mastra/server` package listed in the frontmatter.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 75a428f8-0812-45bd-87a8-bf8850283edd
📒 Files selected for processing (1)
.changeset/fix-zod4-query-param-detection.md
Signed-off-by: intojhanurag <aojharaj2004@gmail.com>
Description
wrapSchemaForQueryParamsrelied on_def.typeNameto detect complex schema types (objects, arrays, records) that need JSON parsing from query strings.Zod v4 uses
_def.typewith lowercase values ("object","optional","array","record") instead of Zod v3's_def.typeName("ZodObject","ZodOptional","ZodArray","ZodRecord"). This causedisComplexType()to returnfalsefor all fields, so complex query params like date ranges were never wrapped withjsonQueryParam()— the raw JSON string failed validation with "Invalid query parameters".The fix updates
getZodTypeName()to check both_def.typeName(v3) and_def.type(v4), and usesSetlookups for both naming conventions inisComplexType().Before
After
Related Issue(s)
Fixes #13962
Type of Change
Checklist
Summary by CodeRabbit