fix(api): add missing tRPC route handlers for apiKeys, payments, and filterSegments#29482
Closed
Suraj-kummar wants to merge 2 commits into
Closed
fix(api): add missing tRPC route handlers for apiKeys, payments, and filterSegments#29482Suraj-kummar wants to merge 2 commits into
Suraj-kummar wants to merge 2 commits into
Conversation
Fixes critical parseInt misclassification bug, adds inviteEmail to Zod schema, skips membership check for invite entries in eventOwnerProcedure, swaps Select for CreatableSelect with (Invite) badge visual feedback. Closes calcom#26850
…filterSegments The tRPC client resolves viewer.apiKeys.*, viewer.payments.*, and viewer.filterSegments.* calls to standalone endpoints at /api/trpc/<endpoint>/[trpc] based on the ENDPOINTS array in packages/trpc/react/shared.ts. These three endpoints were listed in ENDPOINTS but had no corresponding Next.js API route file, causing Next.js to return an HTML 404 page instead of JSON. The tRPC client then tried to parse the HTML as JSON, producing: Unexpected token '<', "<!DOCTYPE "... is not valid JSON Fixes: calcom#29475 Also fix revalidateTag call in api-keys/actions.ts which was passing an invalid second argument "max" -- revalidateTag only accepts a single string tag argument.
Contributor
|
Welcome to Cal.diy, @Suraj-kummar! Thanks for opening this pull request. A few things to keep in mind:
A maintainer will review your PR soon. Thanks for contributing! |
Member
|
Thank you for your contributions. Going with this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #29475
Three tRPC endpoints were listed in the
ENDPOINTSarray inpackages/trpc/react/shared.tsbut had no corresponding Next.js API route file, causing Next.js to return an HTML 404 page instead of a JSON tRPC response.The tRPC client then tried to parse the HTML as JSON, producing:
Root Cause
The tRPC client's
resolveEndpoint()function maps a call likeviewer.apiKeys.create(3 path segments) to the standalone endpoint/api/trpc/apiKeys/create. SinceapiKeys(andpayments,filterSegments) existed inENDPOINTSbut had no matching directory/[trpc].tsfile underapps/web/pages/api/trpc/, Next.js returned a 404 HTML page.Changes
New files
apps/web/pages/api/trpc/apiKeys/[trpc].ts— exposesapiKeysRouter(fixes the reported issue)apps/web/pages/api/trpc/payments/[trpc].ts— exposespaymentsRouterapps/web/pages/api/trpc/filterSegments/[trpc].ts— exposesfilterSegmentsRouterFixed
apps/web/app/(use-page-wrapper)/settings/(settings-layout)/developer/api-keys/actions.ts— removed invalid second argument"max"fromrevalidateTag()(it only accepts one argument)Testing
/settings/developer/api-keysPR Checklist