Skip to content

fix: preserve array query parameters during dynamic group redirect#28789

Draft
jaydeep-pipaliya wants to merge 1 commit intocalcom:mainfrom
jaydeep-pipaliya:fix/array-query-param-serialization
Draft

fix: preserve array query parameters during dynamic group redirect#28789
jaydeep-pipaliya wants to merge 1 commit intocalcom:mainfrom
jaydeep-pipaliya:fix/array-query-param-serialization

Conversation

@jaydeep-pipaliya
Copy link
Copy Markdown

What does this PR do?

Fixes #28687

When a URL contains repeated query parameters (e.g., /john?user=john&user=doe), Next.js parses them as string[]. Passing context.query cast to Record<string, string> into URLSearchParams serializes arrays as comma-separated strings (user=john%2Cdoe), breaking downstream logic.

Fix

Replace the cast with explicit iteration using URLSearchParams.append() per value:

// Before — array values collapsed to comma-separated string
new URLSearchParams(context.query as Record<string, string>)

// After — each value appended individually
const queryParams = new URLSearchParams();
for (const [key, value] of Object.entries(context.query)) {
  if (Array.isArray(value)) {
    value.forEach((v) => queryParams.append(key, v));
  } else if (value !== undefined) {
    queryParams.append(key, value);
  }
}

Changes

  • apps/web/server/lib/[user]/getServerSideProps.ts — fix query string serialization in dynamic group redirect

When context.query contains array values (e.g., user=john&user=doe),
casting to Record<string, string> and passing to URLSearchParams
incorrectly serializes them as user=john,doe.

Fix by iterating entries and using URLSearchParams.append() per value
to preserve multiple values for the same key.

Fixes calcom#28687
@github-actions github-actions bot added the 🐛 bug Something isn't working label Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect serialization of array query parameters in redirect logic

1 participant