Skip to content

fix(platform-atoms): correct copy-paste oversights in providers, hooks, and http helpers#28562

Open
karesansui-u wants to merge 3 commits intocalcom:mainfrom
karesansui-u:fix/platform-atoms-copy-paste-oversights
Open

fix(platform-atoms): correct copy-paste oversights in providers, hooks, and http helpers#28562
karesansui-u wants to merge 3 commits intocalcom:mainfrom
karesansui-u:fix/platform-atoms-copy-paste-oversights

Conversation

@karesansui-u
Copy link

@karesansui-u karesansui-u commented Mar 24, 2026

What does this PR do?

Fixes three small bugs in packages/platform/atoms that 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

CalOAuthProvider inherits Omit<BaseCalProviderProps, "isOAuth2">, which includes onTokenRefreshStart, onTokenRefreshSuccess, and onTokenRefreshError. However, it never destructures or forwards them to BaseCalProvider. Consumers can pass these callbacks without a type error, but they are quietly ignored.

CalProvider already destructures and forwards all three — CalOAuthProvider was created from it as a template and these were missed. BaseCalProvider passes them through to useOAuthFlow, which invokes them during the HTTP 498 token-refresh interceptor cycle, so OAuth2 consumers currently have no way to observe refresh events.

2. useEventTypeById fires a request to /event-types/null when id is null

The hook accepts id: number | null but has no enabled guard on its useQuery call. When id is null (which happens on initial render — BookerStore.eventId initialises as null), 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 (useBooking uses enabled: !!uid, useSchedule uses enabled: isInit, etc.).

3. getVersionHeader reads the wrong header constant

setVersionHeader writes to CAL_API_VERSION_HEADER ("cal-api-version") but getVersionHeader reads from X_CAL_CLIENT_ID ("x-cal-client-id"). The pair was copied from setClientIdHeader/getClientIdHeader — the setter's key was updated but the getter's key was not. The parameter name clientId in setVersionHeader is a leftover from the same copy; callers already pass it as http.setVersionHeader(version). This change restores setter/getter consistency with every other header pair in the file.

How should this be tested?

  1. Render <CalOAuthProvider> with onTokenRefreshStart/onTokenRefreshSuccess/onTokenRefreshError and trigger a token refresh — the callbacks should now fire
  2. Load a booking form where eventId starts as null in the booker store and check the network tab — no /event-types/null requests should appear
  3. Call http.setVersionHeader("2024-06-14") followed by http.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)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A — internal platform atoms, no public docs affected.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works. N/A — no existing test coverage for these files; changes are mechanical and verified against sibling implementations.

Checklist

  • I have read the contributing guide
  • My code follows the style guidelines of this project
  • I have checked that my changes generate no new warnings

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
@karesansui-u karesansui-u requested review from a team as code owners March 24, 2026 13:57
Copy link
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 3 files

@CLAassistant
Copy link

CLAassistant commented Mar 24, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants