Skip to content

fix(url): Base URL recovered from env var is automatically integrated into SDK initialization, instead of relying on being passed during requests.#57

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

fix(url): Base URL recovered from env var is automatically integrated into SDK initialization, instead of relying on being passed during requests.#57
Murike wants to merge 2 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 that custom base URLs for the API were only used if provided in the http requests as one of the options. Since we have GalileoConfig to recover all env vars, this update was provided to make the process more seamless.
During the SDK initialization, before using the default URL provided from the OpenAPI spec, we'll also check if there is data on the env var for this variable. If it does, we'll use it instead. Callers can still overwrite with another URL, but the env var one becomes the default.


Generated description

Below is a concise technical summary of the changes proposed in this PR:
Update SDK initialization to pull default API URL from GalileoConfig before falling back to the spec-defined server, ensuring env var overrides without needing per-request options. Clarify the generated code header to document Galileo’s custom handling of API URL sourcing.

Latest Contributors(2)
UserCommitDate
galileo-automationfeat-codegen-Typescrip...March 06, 2026
Murikefix-overlay-Added-over...February 10, 2026
This pull request is reviewed by Baz. Review like a pro on (Baz).

… into SDK initialization, instead of relying on being passed during requests.
export function serverURLFromOptions(options: SDKOptions): URL | null {
let serverURL = options.serverURL;
const config = GalileoConfig.get();
let serverURL = options.serverURL ?? config.apiUrl;

Choose a reason for hiding this comment

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

Since the type of apiUrl is apiUrl: string | undefined, is it possible that serverURL will be undefined? Can this happen in practice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only way this could happen was if no url was provided in "options" and ServerList is also empty, I believe Speakeasy assigns "string | undefined" as the type here to support this possibility.
Since config.apiUrl will (in the worst case) provide the default "https://api.galileo.ai" URL, not likely to happen now (compiler/lint rules could not figure that this is the case, so I'm maintaining the type for proper support).

Comment on lines 52 to 58
if (!serverURL) {
const serverIdx = options.serverIdx ?? 0;
if (serverIdx < 0 || serverIdx >= ServerList.length) {
throw new Error(`Invalid server index ${serverIdx}`);
}
serverURL = ServerList[serverIdx] || "";
}

Choose a reason for hiding this comment

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

If ServerList is not a source of truth what is the purpose of this code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was originally generated by Speakeasy. I'm avoiding removing Speakeasy generated code as much as possible, to lower possibility of conflicts to be reviewed if the next code generation conflicts here.

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