Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 22, 2025

This PR fixes the failing tests that were broken after adding the baseUrl parameter to getRequestyModels function.

Changes

  • Updated test in src/api/providers/__tests__/requesty.spec.ts to use a valid URL format
  • Updated test in src/api/providers/fetchers/__tests__/modelCache.spec.ts to match the new parameter order (baseUrl, apiKey)

Related to PR #7275


Important

Fix tests for getRequestyModels by updating URL handling and parameter order.

  • Tests:
    • Update requesty.spec.ts to use valid URL format for baseUrl.
    • Update modelCache.spec.ts to match new parameter order in getRequestyModels().
  • Functions:
    • Modify getRequestyModels() in requesty.ts to accept baseUrl and resolve it using toRequestyServiceUrl().
    • Update getModels() in modelCache.ts to pass baseUrl to getRequestyModels().
  • Utilities:
    • Add toRequestyServiceUrl() in utils/requesty.ts to handle URL resolution for requesty services.

This description was created by Ellipsis for 64ac30d. You can customize this summary. It will automatically update as commits are pushed.

requesty-JohnCosta27 and others added 4 commits August 15, 2025 13:50
fixed URL construction for models and balance endpoints
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
@roomote roomote bot requested review from cte, jr and mrubens as code owners August 22, 2025 19:19
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Aug 22, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

Fixed the tests, but forgot to test if the tests test what they're supposed to test.

const result = await getModels({ provider: "requesty", apiKey: DUMMY_REQUESTY_KEY })

expect(mockGetRequestyModels).toHaveBeenCalledWith(DUMMY_REQUESTY_KEY)
expect(mockGetRequestyModels).toHaveBeenCalledWith(undefined, DUMMY_REQUESTY_KEY)
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 test expects getRequestyModels to be called with (undefined, DUMMY_REQUESTY_KEY), but it doesn't actually test the baseUrl parameter properly. Could we add a test case that verifies baseUrl is passed correctly when it's provided in the options?

Suggested change
expect(mockGetRequestyModels).toHaveBeenCalledWith(undefined, DUMMY_REQUESTY_KEY)
it("calls getRequestyModels with baseUrl when provided", async () => {
const mockModels = { /* ... */ }
mockGetRequestyModels.mockResolvedValue(mockModels)
const result = await getModels({
provider: "requesty",
apiKey: DUMMY_REQUESTY_KEY,
baseUrl: "https://custom.requesty.ai/v1"
})
expect(mockGetRequestyModels).toHaveBeenCalledWith("https://custom.requesty.ai/v1", DUMMY_REQUESTY_KEY)
expect(result).toEqual(mockModels)
})

return new URL(url).toString()
} catch (error) {
// If the provided baseUrl is invalid, fall back to the default
console.warn(`Invalid base URL "${baseUrl}", falling back to default`)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it intentional that we silently fall back to the default URL when an invalid baseUrl is provided? In development/test environments, throwing an error might help catch configuration issues early. What do you think about adding an environment check here?

})
})

it("can use a base URL instead of the default", () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could we make this test name more descriptive? Something like "initializes OpenAI client with custom base URL when provided" would be clearer about what's being tested.

if (type === "router") {
return baseUrl
} else {
return baseUrl.replace("router", type).replace("v1", "")
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 URL transformation logic here (replacing 'router' with service type and removing 'v1') seems fragile. What happens if the baseUrl doesn't contain 'router' or 'v1'? Should we add some validation or tests to ensure this works correctly for different URL formats?

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 22, 2025
@daniel-lxs daniel-lxs closed this Aug 23, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Aug 23, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants