Skip to content

fix(url): Removed possible extra character in base URLs, to avoid issues when building path for requests.#516

Open
Murike wants to merge 3 commits intomainfrom
fix/e2e-test-fixes
Open

fix(url): Removed possible extra character in base URLs, to avoid issues when building path for requests.#516
Murike wants to merge 3 commits intomainfrom
fix/e2e-test-fixes

Conversation

@Murike
Copy link
Contributor

@Murike Murike commented Mar 10, 2026

User description

Possible E2E test issues with newly introduced features - sc-57125

Description

While fixing issues with e2e tests, it was observed the way base URLs were used could have issues if the final slash character was already included. Fixed accordingly.

Important: Have the following PR approved before, this one should then update galileo-generated's version.

rungalileo/galileo-ts-generated#57


Generated description

Below is a concise technical summary of the changes proposed in this PR:

graph LR
BaseClient_("BaseClient"):::modified
GALILEO_API_("GALILEO_API"):::modified
log_("log"):::modified
GALILEO_LOGGER_("GALILEO_LOGGER"):::modified
BaseClient_ -- "Adds apiUrl property with trailing-slash trimming." --> GALILEO_API_
log_ -- "Prefers experimentContext metadata for logger configuration." --> GALILEO_LOGGER_
classDef added stroke:#15AA7A
classDef removed stroke:#CD5270
classDef modified stroke:#EDAC4C
linkStyle default stroke:#CBD5E1,font-size:13px
Loading

Normalize how BaseClient stores the API base URL so it strips any trailing slash before building request paths, and keep the getter/setter private to enforce sanitized values. Remove the loggerContext fallback in log so only experiment context data determines logger selection, preventing stale log store data from overriding experiment information.

TopicDetails
Base URL handling Normalize the base URL in BaseClient by trimming any trailing slash when setting apiUrl, ensuring downstream request paths are built from a consistent root.
Modified files (1)
  • src/api-client/base-client.ts
Latest Contributors(2)
UserCommitDate
Murikefeat-config-Importing-...February 06, 2026
vamaq@users.noreply.gi...chore-Include-headers-...September 10, 2025
Logger context flow Prefer experiment context data when creating loggers in log, removing the fallback to loggerContext so stale log store values no longer override the active experiment details.
Modified files (1)
  • src/wrappers.ts
Latest Contributors(2)
UserCommitDate
Murikefeat-logging-Updated-e...February 27, 2026
dmcwhorter@users.norep...rework-logger-paramete...July 16, 2025
This pull request is reviewed by Baz. Review like a pro on (Baz).

headers = { ...headers, ...extraHeaders };

const endpointPath = `${this.apiUrl}/${endpoint
const endpointPath = `${this.apiUrl.replace(/\/$/, '')}/${endpoint
Copy link

@fernandocorreia-galileo fernandocorreia-galileo Mar 10, 2026

Choose a reason for hiding this comment

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

How about doing this in BaseClient instead:

    private _apiUrl: string = '';
    protected get apiUrl(): string {
      return this._apiUrl;
    }
    protected set apiUrl(url: string) {
      this._apiUrl = url.replace(/\/$/, '');
    }
    // ... rest unchanged

Copy link

Choose a reason for hiding this comment

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

Commit f112c61 addressed this comment by introducing a private _apiUrl field with getter/setter logic that strips trailing slashes when the URL is assigned, allowing the request-building code to rely on this.apiUrl without additional trimming.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored for getter-setter.

headers = { ...headers, ...extraHeaders };

const endpointPath = `${this.apiUrl}/${endpoint
const endpointPath = `${this.apiUrl.replace(/\/$/, '')}/${endpoint
Copy link

@fernandocorreia-galileo fernandocorreia-galileo Mar 10, 2026

Choose a reason for hiding this comment

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

src/legacy-api-client.ts line 186 has the same pattern. We should probably do the same there.

Or, if you go with the setter approach in BaseClient, this would be automatically covered
since LegacyApiClient extends BaseClient and its this.apiUrl = this.getApiUrl() assignment would go through the setter.

Copy link

Choose a reason for hiding this comment

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

Commit f112c61 addressed this comment by adding an apiUrl setter on BaseClient that strips trailing slashes before storing the value and by relying on that sanitized property when building endpoints, so any subclass (including LegacyApiClient) now inherits the normalized URL without needing its own replace(//$/, '') logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored for getter-setter.

@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.22%. Comparing base (2bbc9bb) to head (f112c61).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #516      +/-   ##
==========================================
+ Coverage   75.21%   75.22%   +0.01%     
==========================================
  Files          75       75              
  Lines        6741     6737       -4     
  Branches     1860     1854       -6     
==========================================
- Hits         5070     5068       -2     
+ Misses       1660     1658       -2     
  Partials       11       11              
Flag Coverage Δ
unittests 75.22% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/api-client/base-client.ts 88.62% <100.00%> (+0.27%) ⬆️
src/wrappers.ts 92.94% <100.00%> (+0.57%) ⬆️
Files with missing lines Coverage Δ
src/api-client/base-client.ts 88.62% <100.00%> (+0.27%) ⬆️
src/wrappers.ts 92.94% <100.00%> (+0.57%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants