Conversation
… 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; |
There was a problem hiding this comment.
Since the type of apiUrl is apiUrl: string | undefined, is it possible that serverURL will be undefined? Can this happen in practice?
There was a problem hiding this comment.
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).
| if (!serverURL) { | ||
| const serverIdx = options.serverIdx ?? 0; | ||
| if (serverIdx < 0 || serverIdx >= ServerList.length) { | ||
| throw new Error(`Invalid server index ${serverIdx}`); | ||
| } | ||
| serverURL = ServerList[serverIdx] || ""; | ||
| } |
There was a problem hiding this comment.
If ServerList is not a source of truth what is the purpose of this code?
There was a problem hiding this comment.
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.
…sy generated now.
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
GalileoConfigbefore 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)