Skip to content

Commit 0e1a0b6

Browse files
committed
refactor: remove legacy chat template allowlist
1 parent 40740aa commit 0e1a0b6

17 files changed

Lines changed: 4 additions & 540 deletions

‎coderd/coderd.go‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,8 +1395,6 @@ func New(options *Options) *API {
13951395
r.Put("/debug-retention-days", api.putChatDebugRetentionDays)
13961396
r.Get("/auto-archive-days", api.getChatAutoArchiveDays)
13971397
r.Put("/auto-archive-days", api.putChatAutoArchiveDays)
1398-
r.Get("/template-allowlist", api.getChatTemplateAllowlist)
1399-
r.Put("/template-allowlist", api.putChatTemplateAllowlist)
14001398
})
14011399
// TODO(cian): place under /api/experimental/chats/config
14021400
r.Route("/providers", func(r chi.Router) {

‎coderd/database/dbauthz/dbauthz.go‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3618,17 +3618,6 @@ func (q *querier) GetChatSystemPromptConfig(ctx context.Context) (database.GetCh
36183618
return q.db.GetChatSystemPromptConfig(ctx)
36193619
}
36203620

3621-
// GetChatTemplateAllowlist requires deployment-config read permission,
3622-
// unlike the peer getters (GetChatDesktopEnabled, etc.) which only
3623-
// check actor presence. The allowlist is admin-configuration that
3624-
// should not be readable by non-admin users via the HTTP API.
3625-
func (q *querier) GetChatTemplateAllowlist(ctx context.Context) (string, error) {
3626-
if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceDeploymentConfig); err != nil {
3627-
return "", err
3628-
}
3629-
return q.db.GetChatTemplateAllowlist(ctx)
3630-
}
3631-
36323621
func (q *querier) GetChatTitleGenerationModelOverride(ctx context.Context) (string, error) {
36333622
if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceDeploymentConfig); err != nil {
36343623
return "", err
@@ -9026,13 +9015,6 @@ func (q *querier) UpsertChatSystemPrompt(ctx context.Context, value string) erro
90269015
return q.db.UpsertChatSystemPrompt(ctx, value)
90279016
}
90289017

9029-
func (q *querier) UpsertChatTemplateAllowlist(ctx context.Context, templateAllowlist string) error {
9030-
if err := q.authorizeContext(ctx, policy.ActionUpdate, rbac.ResourceDeploymentConfig); err != nil {
9031-
return err
9032-
}
9033-
return q.db.UpsertChatTemplateAllowlist(ctx, templateAllowlist)
9034-
}
9035-
90369018
func (q *querier) UpsertChatTitleGenerationModelOverride(ctx context.Context, value string) error {
90379019
if err := q.authorizeContext(ctx, policy.ActionUpdate, rbac.ResourceDeploymentConfig); err != nil {
90389020
return err

‎coderd/database/dbauthz/dbauthz_test.go‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,10 +1244,6 @@ func (s *MethodTestSuite) TestChats() {
12441244
dbm.EXPECT().GetChatPlanModeInstructions(gomock.Any()).Return("", nil).AnyTimes()
12451245
check.Args().Asserts(rbac.ResourceDeploymentConfig, policy.ActionUpdate)
12461246
}))
1247-
s.Run("GetChatTemplateAllowlist", s.Mocked(func(dbm *dbmock.MockStore, _ *gofakeit.Faker, check *expects) {
1248-
dbm.EXPECT().GetChatTemplateAllowlist(gomock.Any()).Return("", nil).AnyTimes()
1249-
check.Args().Asserts(rbac.ResourceDeploymentConfig, policy.ActionRead)
1250-
}))
12511247
s.Run("GetChatWorkspaceTTL", s.Mocked(func(dbm *dbmock.MockStore, _ *gofakeit.Faker, check *expects) {
12521248
dbm.EXPECT().GetChatWorkspaceTTL(gomock.Any()).Return("1h", nil).AnyTimes()
12531249
check.Args().Asserts()
@@ -1680,10 +1676,6 @@ func (s *MethodTestSuite) TestChats() {
16801676
dbm.EXPECT().UpsertChatPlanModeInstructions(gomock.Any(), "").Return(nil).AnyTimes()
16811677
check.Args("").Asserts(rbac.ResourceDeploymentConfig, policy.ActionUpdate)
16821678
}))
1683-
s.Run("UpsertChatTemplateAllowlist", s.Mocked(func(dbm *dbmock.MockStore, _ *gofakeit.Faker, check *expects) {
1684-
dbm.EXPECT().UpsertChatTemplateAllowlist(gomock.Any(), "").Return(nil).AnyTimes()
1685-
check.Args("").Asserts(rbac.ResourceDeploymentConfig, policy.ActionUpdate)
1686-
}))
16871679
s.Run("UpsertChatWorkspaceTTL", s.Mocked(func(dbm *dbmock.MockStore, _ *gofakeit.Faker, check *expects) {
16881680
dbm.EXPECT().UpsertChatWorkspaceTTL(gomock.Any(), "1h").Return(nil).AnyTimes()
16891681
check.Args("1h").Asserts(rbac.ResourceDeploymentConfig, policy.ActionUpdate)

‎coderd/database/dbmetrics/querymetrics.go‎

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎coderd/database/dbmock/dbmock.go‎

Lines changed: 0 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- No-op. Per-template agents_allowed values cannot be losslessly converted back
2+
-- to the deployment-wide allowlist.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DELETE FROM site_configs
2+
WHERE key = 'agents_template_allowlist';

‎coderd/database/querier.go‎

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎coderd/database/queries.sql.go‎

Lines changed: 0 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎coderd/database/queries/siteconfig.sql‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,6 @@ SET value = CASE
313313
END
314314
WHERE site_configs.key = 'agents_chat_personal_model_overrides_enabled';
315315

316-
-- GetChatTemplateAllowlist returns the JSON-encoded template allowlist.
317-
-- Returns an empty string when no allowlist has been configured (all templates allowed).
318-
-- name: GetChatTemplateAllowlist :one
319-
SELECT
320-
COALESCE((SELECT value FROM site_configs WHERE key = 'agents_template_allowlist'), '') :: text AS template_allowlist;
321-
322316
-- GetChatIncludeDefaultSystemPrompt preserves the legacy default
323317
-- for deployments created before the explicit include-default toggle.
324318
-- When the toggle is unset, a non-empty custom prompt implies false;
@@ -360,10 +354,6 @@ SELECT
360354
'0s'
361355
)::text AS workspace_ttl;
362356

363-
-- name: UpsertChatTemplateAllowlist :exec
364-
INSERT INTO site_configs (key, value) VALUES ('agents_template_allowlist', @template_allowlist)
365-
ON CONFLICT (key) DO UPDATE SET value = @template_allowlist WHERE site_configs.key = 'agents_template_allowlist';
366-
367357
-- name: UpsertChatWorkspaceTTL :exec
368358
INSERT INTO site_configs (key, value)
369359
VALUES ('agents_workspace_ttl', @workspace_ttl::text)

0 commit comments

Comments
 (0)