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".
()
| 282 | // allowlist is empty or cannot be loaded the function returns |
| 283 | // nil, which the tools interpret as "all templates allowed". |
| 284 | func (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 | |
| 309 | func (p *Server) loadAdvisorConfig(ctx context.Context, logger slog.Logger) codersdk.AdvisorConfig { |
| 310 | cfg, err := p.configCache.AdvisorConfig(ctx) |
nothing calls this directly
no test coverage detected