fix(platform-atoms): correct copy-paste oversights in providers, hooks, and http helpers#28562
Open
karesansui-u wants to merge 3 commits intocalcom:mainfrom
Open
fix(platform-atoms): correct copy-paste oversights in providers, hooks, and http helpers#28562karesansui-u wants to merge 3 commits intocalcom:mainfrom
karesansui-u wants to merge 3 commits intocalcom:mainfrom
Conversation
CalOAuthProvider omits onTokenRefreshStart, onTokenRefreshSuccess, and onTokenRefreshError when rendering BaseCalProvider. The type (Omit<BaseCalProviderProps, "isOAuth2">) includes these props, so consumers can pass them without any type error, but they are silently discarded. CalProvider already destructures and forwards these props correctly. BaseCalProvider passes these callbacks to useOAuthFlow, which invokes them during the HTTP 498 token-refresh cycle. Without forwarding them, OAuth2 consumers have no way to hook into refresh lifecycle events. Made-with: Cursor
useEventTypeById accepts `number | null` but does not set `enabled` on its useQuery call. When id is null (e.g. on initial render before the store is populated), the hook sends a request to `/event-types/null`, which returns an error and triggers default retries. Other hooks in the same package (useBooking, useSchedule, useSchedules) already guard against this with an `enabled` condition. Made-with: Cursor
getVersionHeader reads from X_CAL_CLIENT_ID ("x-cal-client-id") instead
of CAL_API_VERSION_HEADER ("cal-api-version"). This makes the getter
return the client ID value rather than the API version that was set by
setVersionHeader. The mismatch was introduced when setVersionHeader was
copied from setClientIdHeader without updating the getter's key.
Also rename the setVersionHeader parameter from `clientId` to `version`
to match its actual purpose, consistent with how callers use it:
http.setVersionHeader(version)
Made-with: Cursor
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.
What does this PR do?
Fixes three small bugs in
packages/platform/atomsthat share a common root cause: props or constants were copied from a sibling implementation but not fully updated for the new context.1. CalOAuthProvider silently drops token refresh callbacks
CalOAuthProviderinheritsOmit<BaseCalProviderProps, "isOAuth2">, which includesonTokenRefreshStart,onTokenRefreshSuccess, andonTokenRefreshError. However, it never destructures or forwards them toBaseCalProvider. Consumers can pass these callbacks without a type error, but they are quietly ignored.CalProvideralready destructures and forwards all three —CalOAuthProviderwas created from it as a template and these were missed.BaseCalProviderpasses them through touseOAuthFlow, which invokes them during the HTTP 498 token-refresh interceptor cycle, so OAuth2 consumers currently have no way to observe refresh events.2.
useEventTypeByIdfires a request to/event-types/nullwhen id is nullThe hook accepts
id: number | nullbut has noenabledguard on itsuseQuerycall. Whenidisnull(which happens on initial render —BookerStore.eventIdinitialises asnull), the pathname resolves to the string"/event-types/null"and the request fails. Every other nullable-parameter hook in the same package already guards against this (useBookingusesenabled: !!uid,useScheduleusesenabled: isInit, etc.).3.
getVersionHeaderreads the wrong header constantsetVersionHeaderwrites toCAL_API_VERSION_HEADER("cal-api-version") butgetVersionHeaderreads fromX_CAL_CLIENT_ID("x-cal-client-id"). The pair was copied fromsetClientIdHeader/getClientIdHeader— the setter's key was updated but the getter's key was not. The parameter nameclientIdinsetVersionHeaderis a leftover from the same copy; callers already pass it ashttp.setVersionHeader(version). This change restores setter/getter consistency with every other header pair in the file.How should this be tested?
<CalOAuthProvider>withonTokenRefreshStart/onTokenRefreshSuccess/onTokenRefreshErrorand trigger a token refresh — the callbacks should now fireeventIdstarts asnullin the booker store and check the network tab — no/event-types/nullrequests should appearhttp.setVersionHeader("2024-06-14")followed byhttp.getVersionHeader()— it should return"2024-06-14"Existing behaviour without these props/parameters is unchanged; all three are optional and guarded.
Mandatory Tasks (DO NOT REMOVE)
Checklist