Skip to content

fix(sdk-rtl): widen IAccessToken.refresh_token to accept null - #1736

Open
marc-wilson wants to merge 1 commit into
looker-open-source:mainfrom
marc-wilson:fix/iaccesstoken-refresh-token-type
Open

fix(sdk-rtl): widen IAccessToken.refresh_token to accept null#1736
marc-wilson wants to merge 1 commit into
looker-open-source:mainfrom
marc-wilson:fix/iaccesstoken-refresh-token-type

Conversation

@marc-wilson

Copy link
Copy Markdown

What

@looker/sdk and @looker/sdk-rtl both declare an IAccessToken interface with the same name but incompatible shapes for refresh_token:

  • @looker/sdk (packages/sdk/src/4.0/models.ts): refresh_token?: string | null — matches the actual Looker API response shape
  • @looker/sdk-rtl (packages/sdk-rtl/src/authSession.ts): refresh_token?: string — narrower, re-declared independently of model generation

This meant a login_user() response (typed with the sdk's IAccessToken) couldn't be passed directly into AuthToken.setToken()/constructor (typed with the rtl's IAccessToken) without a manual null -> undefined cast at the call site:

error TS2345: Argument of type '.../@looker/sdk/lib/4.0/models".IAccessToken' is not assignable
to parameter of type '.../@looker/sdk-rtl/lib/authSession".IAccessToken'.
  Types of property 'refresh_token' are incompatible.
    Type 'string | null | undefined' is not assignable to type 'string | undefined'.
      Type 'null' is not assignable to type 'string | undefined'.

Fix

Widen sdk-rtl's IAccessToken.refresh_token to string | null, matching @looker/sdk's shape. @looker/sdk depends on @looker/sdk-rtl (not the reverse), so widening the rtl-side declaration is the only direction that doesn't introduce a circular package dependency.

This is a type-only change with no behavior difference: AuthToken.setToken() already does if (token.refresh_token) { ... }, so null and undefined are already treated identically at runtime — a nil refresh_token means "keep using the existing refresh token."

Verification

  • Added packages/sdk/src/4.0/accessTokenCompat.spec.ts, which constructs an @looker/sdk IAccessToken with refresh_token: null and passes it directly into sdk-rtl's AuthToken with no cast.
  • Confirmed the fix is load-bearing: temporarily reverted just the one-line type widening and ran npx tsc -p tsconfig.json (full monorepo, source-level typecheck) — reproduced the exact TS2345 error from this issue. Restored the fix and reran — zero errors across the whole repo.
  • Full monorepo tsc -p tsconfig.json passes cleanly with the fix in place.
  • yarn build passes across all 21 packages.
  • Ran full jest suites for sdk, sdk-rtl, sdk-node, hackathon: same pass/fail counts on this branch as on main (548 passed; 5 pre-existing failures require a live looker.ini/Looker connection, unrelated to this change).

Fixes #1729

Test plan

  • npx tsc -p tsconfig.json (full monorepo typecheck) passes with zero errors
  • yarn build passes cleanly across all 21 packages
  • New test in packages/sdk/src/4.0/accessTokenCompat.spec.ts passes
  • Confirmed via revert that the fix is what resolves the type error (not incidental)
  • No regressions in existing sdk / sdk-rtl / sdk-node / hackathon test suites

`@looker/sdk`'s `IAccessToken.refresh_token` is `string | null | undefined`,
matching the actual Looker API response shape, while `@looker/sdk-rtl`'s
re-declared `IAccessToken` only allowed `string | undefined`. This meant a
`login_user()` response couldn't be passed directly into
`AuthToken.setToken()`/constructor without a manual `null -> undefined` cast.

Widen sdk-rtl's `IAccessToken.refresh_token` to `string | null` to match.
`AuthToken.setToken()` already treats a nil `refresh_token` (undefined or
null) as "keep the existing refresh token", so this is a type-only change
with no behavior difference.

Fixes looker-open-source#1729
@marc-wilson
marc-wilson requested a review from a team as a code owner July 27, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IAccessToken interface conflicts between @looker/sdk and @looker/sdk-rtl (refresh_token nullability)

1 participant