Skip to content

fix: strip trailing slashes from base_url across SDKs - #1803

Merged
drstrangelooker merged 4 commits into
mainfrom
fix/base-url-trailing-slash
Nov 16, 2026
Merged

drstrangelooker merged 4 commits into
mainfrom
fix/base-url-trailing-slash

Conversation

@drstrangelooker

Copy link
Copy Markdown
Collaborator

Summary

Fixes double-slash request URLs (e.g. POST //api/4.0/login returning 403 Forbidden) across all six language SDKs when base_url (or looker_url) is configured with one or more trailing slashes:

  1. Python (python/looker_sdk/rtl/api_settings.py, auth_session.py, api_methods.py):
    • Strip trailing slashes after unquoting base_url and looker_url in ApiSettings (__init__ and _clean_input), treating slash-only values as unconfigured.
    • Strip trailing slashes defensively when constructing /login, /login/{sudo_id}, /logout, /auth, and api_path URLs.
  2. TypeScript / Node (packages/sdk-rtl, packages/sdk-node, packages/sdk, packages/sdk-codegen, packages/sdk-codegen-scripts):
    • Add stripTrailingSlashes in @looker/sdk-rtl (constants.ts) and apply it in ApiSettings, ValueSettings, readEnvConfig, readIniConfig, APIMethods.makePath, functionalSdk, BaseTransport.makeUrl, TypescriptGen, Looker40SDK, Looker40SDKStream, and fetchSpec.
  3. Kotlin (kotlin/src/main/com/looker/sdk/ApiSettings.kt, rtl/Transport.kt, rtl/OAuthSession.kt):
    • Trim trailing slashes from baseUrl / base_url / looker_url in ApiSettings, Transport, and OAuthSession.
  4. C# (csharp/rtl/ApiSettings.cs, ApiMethods.cs, Transport.cs):
    • Trim quotes and trailing slashes in ApiSettings.BaseUrl / ReadConfig and guard _apiPath, MakePath, and Transport.MakeUrl.
  5. Swift (swift/looker/rtl/constants.swift, apiSettings.swift, apiConfig.swift, baseTransport.swift, oauthSession.swift):
    • Add stripTrailingSlashes and apply across ValueSettings, ApiSettings, ApiConfig, BaseTransport.makeUrl, and OAuthSession.
  6. Go (go/rtl/settings.go, auth.go):
    • Normalize BaseUrl in NewSettingsFromFile, NewSettingsFromEnv, NewAuthSessionWithTransport, and AuthSession.Do.

Testing

  • Python: pytest tests/rtl/ & black --check
  • TypeScript / Node: yarn jest, yarn lint:ts (tsc), & eslint
  • Kotlin: ./gradlew test & ./gradlew jar
  • C#: dotnet test (RTL unit tests)
  • Swift: swiftc RTL unit test verification
  • Go: go test -v ./rtl/... & go build ./...

Developer Checklist ℹ️

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Appropriate docs were updated (if necessary)

Fixes #1714 🦕

@drstrangelooker
drstrangelooker requested a review from a team as a code owner November 16, 2026 21:48
Comment thread packages/sdk-rtl/src/constants.ts Dismissed

@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 implements a robust normalization strategy for base URLs across multiple SDK languages (C#, Go, Kotlin, Swift, TypeScript, and Python) by stripping trailing slashes and surrounding quotes. This ensures consistent URL construction and prevents issues with double slashes in API requests. My review highlights potential nullability and case-sensitivity issues in the configuration parsing logic that should be addressed to improve reliability.

Comment thread csharp/rtl/ApiSettings.cs Resolved
Comment thread python/looker_sdk/rtl/api_settings.py Resolved
Comment thread python/looker_sdk/rtl/auth_session.py Resolved
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Go Tests

  7 files    7 suites   3m 21s ⏱️
 54 tests  54 ✅ 0 💤 0 ❌
138 runs  138 ✅ 0 💤 0 ❌

Results for commit cf60e01.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Codegen Tests

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit cf60e01.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Python Tests

 11 files   11 suites   1m 37s ⏱️
158 tests 153 ✅  5 💤 0 ❌
923 runs  895 ✅ 28 💤 0 ❌

Results for commit cf60e01.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Typescript Tests

  2 files  ± 0   64 suites  ±0   1m 10s ⏱️ +20s
252 tests + 6  249 ✅ + 6  3 💤 ±0  0 ❌ ±0 
532 runs  +12  526 ✅ +12  6 💤 ±0  0 ❌ ±0 

Results for commit cf60e01. ± Comparison against base commit cf856d8.

♻️ This comment has been updated with latest results.

drstrangelooker and others added 3 commits November 16, 2026 17:12
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@drstrangelooker
drstrangelooker merged commit 21b6ed1 into main Nov 16, 2026
49 checks passed
@drstrangelooker
drstrangelooker deleted the fix/base-url-trailing-slash branch November 16, 2026 22:25
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.

Python SDK: trailing slash in base_url causes double-slash URLs and auth failure

3 participants