Files
coder/coderd/chat_routes_test.go
T
Ethan 0f5c7b3154 refactor!: remove default organization model routes (#28632)
> [!IMPORTANT]
> Most of the added lines in this PR are generated API reference content
for publishing the organization-scoped `GET` and `POST
/api/v2/organizations/{organization}/chats/models` replacements. There
is no matching generated-doc deletion because the three removed
default-organization endpoints are experimental and are not present in
the generated public API reference on the current base. The removed
paths remain only as explicit 404 reservations, with no
default-organization shim or functional handler.

## Summary

Remove the unused default-organization chat model collection routes:

```text
GET  /api/experimental/chats/models
GET  /api/experimental/chats/model-configs
POST /api/experimental/chats/model-configs
```

Use the organization-scoped collection instead:

```text
GET  /api/v2/organizations/{organization}/chats/models
POST /api/v2/organizations/{organization}/chats/models
```

## Context

The intention of PR #28440 was to consolidate model availability into
the organization-scoped models collection for CODAGT-898 and remove the
superseded collection routes. That PR removed
`/organizations/{organization}/chats/models/available`, but it missed
these older default-organization routes and explicitly retained one of
them. This PR completes the intended #28440 cutover. The repository has
no SDK, CLI, or frontend consumer for the removed routes.

This change also prevents PR #28496 from promoting the missed
default-organization `/chats/models` route into the stable `/api/v2`
API.

This change is separate from the one-release `/api/experimental`
compatibility window in CODAGT-921. That window preserves experimental
versions of the intended stable API. It does not require compatibility
routes for unused deployment-scoped endpoints.

Refs CODAGT-898.

## Breaking change

Clients that call the removed routes must use the organization-scoped
model collection and provide an organization.

## Changelog

Remove unused default-organization Coder Agents model API routes. API
clients must use the organization-scoped chat models collection.

> [!NOTE]
> Coder Agents generated this pull request on Ethan Dickson's behalf.
2026-08-27 10:49:14 +01:00

68 lines
2.3 KiB
Go

package coderd_test
import (
"fmt"
"net/http"
"testing"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/coderd/coderdtest"
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/dbgen"
"github.com/coder/coder/v2/testutil"
)
func TestChatRoutesCompatibility(t *testing.T) {
t.Parallel()
ctx := testutil.Context(t, testutil.WaitLong)
client, db := coderdtest.NewWithDatabase(t, nil)
firstUser := coderdtest.CreateFirstUser(t, client)
model := dbgen.ChatModelConfig(t, db, database.ChatModelConfig{
OrganizationID: firstUser.OrganizationID,
})
chat := dbgen.Chat(t, db, database.Chat{
OrganizationID: firstUser.OrganizationID,
OwnerID: firstUser.UserID,
LastModelConfigID: model.ID,
})
for _, route := range []string{
"/api/experimental/chats",
"/api/experimental/chats/config/system-prompt",
"/api/v2/chats",
"/api/v2/chats/config/system-prompt",
} {
res, err := client.Request(ctx, http.MethodGet, route, nil)
require.NoError(t, err)
_ = res.Body.Close()
require.Equal(t, http.StatusOK, res.StatusCode, route)
}
for _, route := range []struct {
method string
path string
}{
{http.MethodGet, "/api/experimental/chats/models"},
{http.MethodGet, "/api/experimental/chats/model-configs"},
{http.MethodPost, "/api/experimental/chats/model-configs"},
{http.MethodGet, "/api/v2/chats/model-configs"},
{http.MethodPost, "/api/v2/chats/model-configs"},
{http.MethodGet, "/api/v2/chats/providers"},
{http.MethodGet, "/api/v2/chats/user-provider-configs"},
{http.MethodGet, "/api/v2/chats/config/computer-use-provider"},
{http.MethodGet, "/api/v2/chats/config/advisor"},
{http.MethodGet, fmt.Sprintf("/api/v2/chats/%s/debug/runs", chat.ID)},
{http.MethodGet, fmt.Sprintf("/api/v2/chats/%s/stream/desktop", chat.ID)},
{http.MethodGet, fmt.Sprintf("/api/experimental/organizations/%s/mcp-servers/not-a-uuid/acl/available", firstUser.OrganizationID)},
{http.MethodGet, "/api/v2/mcp/servers/not-a-uuid/oauth2/callback"},
{http.MethodPost, "/api/v2/mcp/http/server"},
} {
res, err := client.Request(ctx, route.method, route.path, nil)
require.NoError(t, err)
_ = res.Body.Close()
require.Equal(t, http.StatusNotFound, res.StatusCode, "%s %s", route.method, route.path)
}
}