Skip to content

fix: isolate paging observers, fix settings precedence, and encode sudo IDs - #1817

Merged
drstrangelooker merged 1 commit into
mainfrom
fix/node-session-settings-and-paging
Dec 3, 2026
Merged

drstrangelooker merged 1 commit into
mainfrom
fix/node-session-settings-and-paging

Conversation

@minhaz

@minhaz minhaz commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes several session, configuration, and concurrency bugs across @looker/sdk-rtl, @looker/sdk-node, and looker-sdk (Python):

  1. Single-segment sudoId encoding & sudo response validation (NodeSession, Python AuthSession)

    • Validate and percent-encode sudoId as a single path segment in NodeSession._login() (packages/sdk-node/src/nodeSession.ts) and AuthSession._login_sudo() (python/looker_sdk/rtl/auth_session.py), rejecting empty, ., .., or path-separator values before issuing requests.
    • Throw an SDKError and reset _sudoToken in NodeSession._login() if a sudo login response omits access_token, ensuring isAuthenticated() remains false.
    • Handle numeric 0 cleanly in NodeSession.login() so it is not treated as an empty sudoId, and add a regression test confirming APIMethods 401 retries keep sudo state isolated when sudo re-authentication fails.
  2. NodeSettings env-var precedence & verify_ssl boolean parsing (@looker/sdk-node, @looker/sdk-rtl)

    • Fix the spread order in NodeSettings.constructor (packages/sdk-node/src/nodeSettings.ts) to { ...settings, ...readEnvConfig(envPrefix) } so environment variables override constructor-supplied values as documented.
    • Ignore empty or whitespace-only *_VERIFY_SSL environment values in readEnvConfig().
    • Replace isTrue(...) with boolDefault(unquote(...).trim(), true) in ApiSettings.constructor (and trim in ValueSettings), so undefined, empty, or unrecognized values default to true rather than false.
    • Update verifySsl() (packages/sdk-rtl/src/transport.ts) to check options.verify_ssl !== undefined ? Boolean(options.verify_ssl) : true so { verify_ssl: undefined } does not evaluate falsy in NodeTransport.initRequest().
  3. Concurrency-safe Paging observer capture (@looker/sdk-rtl, @looker/sdk-node)

    • Remove mutation of the shared transport.observer property in Paging.rawCatch() (packages/sdk-rtl/src/paging.ts).
    • Support an optional per-request observer on ITransportSettings and bind Paging's capture observer through synchronous scoped dispatch (withScopedObserver / getScopedObserver / observeResponse) across APIMethods.authRequest, BrowserTransport, NodeTransport, and ExtensionTransport.
    • Composes cleanly with any pre-existing transport.observer while preventing concurrent pager() / pageAll() calls on a shared SDK instance from cross-contaminating Link headers or page results.

Testing

  • TypeScript / Node (Jest): packages/sdk-rtl/src and packages/sdk-node/src — 18 suites passed (1 skipped), 166 tests passed (3 skipped), 0 failures.
  • ESLint: 0 errors, 0 warnings across all 15 modified .ts files.
  • TypeScript build: tsc -b packages/sdk-rtl/tsconfig.build.json packages/sdk/tsconfig.build.json packages/sdk-node/tsconfig.build.json passed with 0 errors.
  • Python (pytest & mypy): tests/rtl/ — 149 passed, 3 skipped, 0 failures; mypy looker_sdk/ — 0 issues in 19 source files.

Developer Checklist

  • Ensure the tests and linter pass
  • Appropriate tests were added for all fixes

@minhaz
minhaz requested a review from a team as a code owner December 3, 2026 18:17

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several security and robustness improvements across the Node and Python Looker SDKs. Key changes include strict validation and URL encoding of sudoId parameters to prevent path traversal vulnerabilities, robust handling of the verify_ssl configuration to ensure SSL verification defaults to true when empty or undefined, and isolated per-request observers to prevent race conditions during concurrent paging. One review comment was kept, which correctly identifies a redundant logical check in nodeSession.ts that causes unnecessary login attempts when a truthy targetId is provided.

Comment thread packages/sdk-node/src/nodeSession.ts Resolved
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Python Tests

   11 files     11 suites   1m 45s ⏱️
  183 tests   178 ✅  5 💤 0 ❌
1 037 runs  1 009 ✅ 28 💤 0 ❌

Results for commit d2f4eb9.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Typescript Tests

  2 files   68 suites   1m 2s ⏱️
283 tests 280 ✅ 3 💤 0 ❌
594 runs  588 ✅ 6 💤 0 ❌

Results for commit d2f4eb9.

♻️ This comment has been updated with latest results.

…do IDs

- Validate and percent-encode sudoId as a single path segment in NodeSession._login and Python AuthSession._login_sudo, and throw while resetting _sudoToken if a sudo login response lacks an access_token.
- Fix NodeSettings constructor spread order so environment variables override constructor-supplied settings as documented, and ignore empty verify_ssl environment values.
- Use boolDefault(..., true) in ApiSettings and check options.verify_ssl !== undefined in verifySsl() so empty, unrecognized, or undefined values default to true.
- Avoid mutating shared transport.observer in Paging.rawCatch by binding per-request observers through ITransportSettings and scoped dispatch so concurrent pager() and pageAll() calls stay isolated.
@drstrangelooker
drstrangelooker force-pushed the fix/node-session-settings-and-paging branch from 5f31558 to d2f4eb9 Compare December 3, 2026 18:34
@drstrangelooker
drstrangelooker merged commit 1d02040 into main Dec 3, 2026
37 checks passed
@drstrangelooker
drstrangelooker deleted the fix/node-session-settings-and-paging branch December 3, 2026 19:04
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.

3 participants