MCPcopy Index your code
hub / github.com/coder/coder / chatTemplateAllowlist

Method chatTemplateAllowlist

coderd/x/chatd/chatd.go:284–307  ·  view source on GitHub ↗

chatTemplateAllowlist returns the deployment-wide template allowlist as a set of permitted template IDs. The callback signature matches what the chat tools expect. When the allowlist is empty or cannot be loaded the function returns nil, which the tools interpret as "all templates allowed".

()

Source from the content-addressed store, hash-verified

282// allowlist is empty or cannot be loaded the function returns
283// nil, which the tools interpret as "all templates allowed".
284func (p *Server) chatTemplateAllowlist() map[uuid.UUID]bool {
285 //nolint:gocritic // AsChatd provides narrowly-scoped daemon
286 // access for reading deployment config.
287 ctx, cancel := context.WithTimeout(context.Background(), time.Second)
288 defer cancel()
289 //nolint:gocritic // AsChatd provides narrowly-scoped read
290 // access to deployment config (the template allowlist).
291 ctx = dbauthz.AsChatd(ctx)
292 raw, err := p.db.GetChatTemplateAllowlist(ctx)
293 if err != nil {
294 p.logger.Warn(ctx, "failed to load chat template allowlist", slog.Error(err))
295 return nil
296 }
297 ids, err := xjson.ParseUUIDList(raw)
298 if err != nil {
299 p.logger.Warn(ctx, "failed to parse chat template allowlist", slog.Error(err))
300 return nil
301 }
302 m := make(map[uuid.UUID]bool, len(ids))
303 for _, id := range ids {
304 m[id] = true
305 }
306 return m
307}
308
309func (p *Server) loadAdvisorConfig(ctx context.Context, logger slog.Logger) codersdk.AdvisorConfig {
310 cfg, err := p.configCache.AdvisorConfig(ctx)

Callers

nothing calls this directly

Calls 4

AsChatdFunction · 0.92
ParseUUIDListFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected