Skip to content

Fix: API Try It double-slash URL causing 404 errors#2951

Open
sakshamarora-arch wants to merge 1 commit into
LambdaTest:stagefrom
sakshamarora-arch:fix/api-tryit-double-slash-stage
Open

Fix: API Try It double-slash URL causing 404 errors#2951
sakshamarora-arch wants to merge 1 commit into
LambdaTest:stagefrom
sakshamarora-arch:fix/api-tryit-double-slash-stage

Conversation

@sakshamarora-arch
Copy link
Copy Markdown
Contributor

Summary

  • Bug: The "Send" button on API documentation pages (Try It feature) was producing malformed URLs with double slashes (e.g. test-manager-api.lambdatest.com//api/v1/...), resulting in 404 errors that surfaced as CORS / "Failed to fetch" errors in the browser.
  • Root cause: OpenAPI specs for Test Manager, User Management, and Audit Logs have a trailing / in their server URL. When concatenated with endpoint paths (which start with /), this produced // in the URL.
  • Fix: Strip trailing slashes from the server base URL before concatenating with the endpoint path in both handleSend() and buildCurl() in TryItModal.js.

Affected APIs

API Before (broken) After (fixed)
Test Manager https://test-manager-api.lambdatest.com//api/v1/... → 404 https://test-manager-api.lambdatest.com/api/v1/... → ✅
User Management https://auth.lambdatest.com//api/... → 404 https://auth.lambdatest.com/api/... → ✅
Audit Logs https://audit-logs.lambdatest.com//api/... → 404 https://audit-logs.lambdatest.com/api/... → ✅

Other 9 APIs (Selenium, Screenshots, App Automation, SmartUI, Cypress, HyperExecute, Accessibility, Analytics, Performance) are unaffected — their server URLs had no trailing slash.

Test plan

  • Open Test Manager API page → Try It → Send → verify single slash in URL and successful response
  • Open User Management API page → Try It → Send → verify same
  • Open Selenium Automation API page → Try It → Send → verify still works as before
  • Check generated cURL commands also have correct URLs

🤖 Generated with Claude Code

Strip trailing slash from server base URL before concatenating with
endpoint path. APIs like Test Manager, User Management, and Audit Logs
have a trailing slash in their OpenAPI spec server URL, which produced
URLs like `test-manager-api.lambdatest.com//api/v1/...` — returning 404.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
surishubham pushed a commit that referenced this pull request May 18, 2026
Three OpenAPI specs (Test Manager, User Management, Audit Logs) declare
server URLs ending with `/`. Concatenating with `endpoint.path` (which
starts with `/`) produced `//api/v1/...`, returning 404 and surfacing in
browsers as "Failed to fetch"/CORS errors.

PR #2951 patched 2 sites in TryItModal.js. This commit covers the
remaining surfaces so every URL shown to the user — visual, copied,
or sent — is clean:

TryItModal.js (5 sites):
- buildCurl URL concatenation
- selectedServer initial state
- selectedServer useEffect sync on endpoint change
- send-request URL
- server dropdown <option> values

EndpointDetail.js (4 sites):
- selectedBase initial state
- selectedBase useEffect sync on endpoint change
- copyUrl clipboard URL
- server dropdown <option> values

langUtils.js (1 site):
- generateCodeExample URL (used by all language snippets:
  cURL/JavaScript/Python/Node/Ruby/Go)

Approach: strip trailing slash at two layers — at the source (state +
<option> values) so the URL bar displays cleanly, and again at
concatenation sites as defense in depth. Uses .replace(/\/+$/, '')
which is a no-op when no trailing slash exists, so APIs without the
defect are unaffected.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
surishubham pushed a commit that referenced this pull request May 18, 2026
Three OpenAPI specs (Test Manager, User Management, Audit Logs) declare
server URLs ending with `/`. Concatenating with `endpoint.path` (which
starts with `/`) produced `//api/v1/...`, returning 404 and surfacing in
browsers as "Failed to fetch"/CORS errors.

PR #2951 patched 2 sites in TryItModal.js. This commit covers the
remaining surfaces so every URL shown to the user — visual, copied,
or sent — is clean:

TryItModal.js (5 sites):
- buildCurl URL concatenation
- selectedServer initial state
- selectedServer useEffect sync on endpoint change
- send-request URL
- server dropdown <option> values

EndpointDetail.js (4 sites):
- selectedBase initial state
- selectedBase useEffect sync on endpoint change
- copyUrl clipboard URL
- server dropdown <option> values

langUtils.js (1 site):
- generateCodeExample URL (used by all language snippets:
  cURL/JavaScript/Python/Node/Ruby/Go)

Approach: strip trailing slash at two layers — at the source (state +
<option> values) so the URL bar displays cleanly, and again at
concatenation sites as defense in depth. Uses .replace(/\/+$/, '')
which is a no-op when no trailing slash exists, so APIs without the
defect are unaffected.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant