Skip to content

fix: preserve array query parameters in redirect logic#28734

Open
TheBhowmik wants to merge 7 commits intocalcom:mainfrom
TheBhowmik:fix/issue-28687-serialization
Open

fix: preserve array query parameters in redirect logic#28734
TheBhowmik wants to merge 7 commits intocalcom:mainfrom
TheBhowmik:fix/issue-28687-serialization

Conversation

@TheBhowmik
Copy link
Copy Markdown

What does this PR do?

This PR fixes the incorrect serialization of array query parameters within the getServerSideProps redirect logic.

Previously, the code used an unsafe type cast (as Record<string, string>) when initializing URLSearchParams. This caused query parameters with multiple values (e.g., ?test=a&test=b) to be merged into a single string separated by a comma (e.g., ?test=a,b) during server-side redirects.

Changes:

Removed the unsafe type casting that forced arrays into strings.

Implemented a robust loop that iterates through context.query entries.

Used URLSearchParams.append() to ensure that each value in an array is preserved as an individual key-value pair in the resulting query string.

Fixes #28687

Visual Demo (For contributors especially)

Image Demo :

Before Fix (Buggy)
.../15min?test=apple,banana

After Fix (Correct)
.../15min?test=apple&test=banana

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code
  • N/A
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

Screenshot 2026-04-04 025356 Screenshot 2026-04-04 155624
  1. Start the development server and navigate to a user profile page with repeated query parameters: http://localhost:3000/wow?test=apple&test=banana

  2. Click on any event type card (e.g., "15 min meeting") to trigger the server-side redirect logic in getServerSideProps.ts.

  3. Expected Result: The final redirected URL should preserve the ampersand separator: localhost:3000/wow/15min?test=apple&test=banana&...

  4. Original Buggy Behavior: The URL would incorrectly squash the values into a single string: localhost:3000/wow/15min?test=apple,banana&...

  • Are there environment variables that should be set?
    No. This is a logic fix for standard URL serialization.

  • What are the minimal test data to have?
    A local user profile (e.g., /wow) and at least one active Event Type (e.g., "15 min meeting").

  • What is expected (happy path) to have (input and output)?
    Input: Navigating to /[user]?test=a&test=b and clicking an event card.
    Output: Redirecting to /[user]/[event]?test=a&test=b (preserving the & separator).

  • Any other important info that could help to test that PR
    This fix replaces an unsafe type cast that was causing URLSearchParams to treat arrays as single comma-separated strings.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 4, 2026

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the 🐛 bug Something isn't working label Apr 4, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/web/server/lib/[user]/getServerSideProps.ts">

<violation number="1" location="apps/web/server/lib/[user]/getServerSideProps.ts:118">
P2: Scalar empty-string query parameters are silently dropped by the new `if (value)` filter, changing redirect query semantics (e.g., `?foo=` is removed).</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

@TheBhowmik
Copy link
Copy Markdown
Author

@cubic-dev-ai I have addressed this in my latest commit by explicitly checking for null and undefined. Please re-verify.

@cubic-dev-ai
Copy link
Copy Markdown
Contributor

cubic-dev-ai bot commented Apr 4, 2026

@cubic-dev-ai I have addressed this in my latest commit by explicitly checking for null and undefined. Please re-verify.

@TheBhowmik I have started the AI code review. It will take a few minutes to complete.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Copy link
Copy Markdown
Member

@sahitya-chandra sahitya-chandra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clean up the comments

@TheBhowmik
Copy link
Copy Markdown
Author

"Done! I've removed the comments, cleaned up the unused imports/variables, and updated the branch with the latest changes from main. Ready for another look!"

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

3 participants