fix: preserve base URL path segments in buildUrl() for Managed Dynatrace hosts - #284
Conversation
…ace and similar hosts Strip the leading '/' from path before new URL(path, base) so that an absolute-path reference does not resolve against the origin and silently discard path components already present in base (e.g. /e/<environment-id> for Dynatrace Managed clusters). Fixes #283 — recurrence of BUG-4 root cause (same WHATWG URL spec behavior that dropped /artifactory from Artifactory base URLs in PR #94). Co-authored-by: Sunny Kolattukudy <kolatts@users.noreply.github.com>
|
Claude finished @github-actions[bot]'s task in 2m 26s —— View job PR Review
PASS — Clean fix, correct analysis, solid test. Root causeThe diagnosis is accurate. Fix (
|
There was a problem hiding this comment.
PASS — Clean fix at the right layer. Root cause correctly identified (WHATWG URL spec absolute-path reference discards base path segments). Stripping a leading / from path in buildUrl() before constructing new URL() is the minimal correct fix. Backward-compatible for all existing services with bare-origin base URLs. New test directly exercises the Dynatrace Managed multi-environment URL pattern. 397 tests pass. Good to merge.
…i/api/ after buildUrl fix) (#287) * fix: drop leading /api/ from CheckmarxClient paths to fix doubled segment after buildUrl() fix CheckmarxClient used absolute paths like /api/projects while checkmarx.baseUrl already ends with /api (e.g. https://tenant.cxone.cloud/api). After PR #284 correctly fixed buildUrl() to preserve base path segments, the combination produced /api/api/projects. Fix paths to be relative (projects, scans, results/summary) so they resolve correctly against the /api base — mirrors the same fix applied to Artifactory in BUG-4. Closes #285 Co-authored-by: Sunny Kolattukudy <kolatts@users.noreply.github.com> * docs: update Checkmarx API base URL --------- Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Sunny Kolattukudy <kolatts@users.noreply.github.com>
…i/api/ after buildUrl fix) (#287) * fix: drop leading /api/ from CheckmarxClient paths to fix doubled segment after buildUrl() fix CheckmarxClient used absolute paths like /api/projects while checkmarx.baseUrl already ends with /api (e.g. https://tenant.cxone.cloud/api). After PR #284 correctly fixed buildUrl() to preserve base path segments, the combination produced /api/api/projects. Fix paths to be relative (projects, scans, results/summary) so they resolve correctly against the /api base — mirrors the same fix applied to Artifactory in BUG-4. Closes #285 Co-authored-by: Sunny Kolattukudy <kolatts@users.noreply.github.com> * docs: update Checkmarx API base URL --------- Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Sunny Kolattukudy <kolatts@users.noreply.github.com>
Problem
dynatracecommands fail with HTTP 404 whenbaseUrlincludes a path component (e.g.https://dynatrace.imagile.dev/e/abc12345-0000-0000-0000-000000000000for Dynatrace Managed multi-environment clusters). The/e/<environment-id>segment was silently dropped, so requests landed athttps://dynatrace.imagile.dev/api/v2/entitiesinstead of the correcthttps://dynatrace.imagile.dev/e/abc12345-0000-0000-0000-000000000000/api/v2/entities.This is the same root cause as BUG-4 (Artifactory
baseUrl-with-path, fixed in PR #94):buildUrl()callsnew URL(path, base)wherepathstarts with/. Per the WHATWG URL spec, an absolute-path reference resolves against the origin, discarding any path already present inbase.Fix
Strip a single leading
/frompathinside the sharedbuildUrl()function insrc/lib/http.tsbefore constructing the URL. BecausebuildUrl()already ensuresbaseends with/, the resulting relative path resolves correctly against the full base (including any path component).PR #94 worked around BUG-4 by removing the leading slash from Artifactory path constants, leaving the underlying flaw in
buildUrl()itself. This fix closes that gap at the source so future services with context-root base URLs don't hit it again.Changes
src/lib/http.ts—buildUrl(): strip leading/frompathbeforenew URL()src/lib/http.test.ts— new test: Dynatrace Managed base URL preserves/e/<environment-id>path segmentVerification
Closes #283
Generated with Claude Code