Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,14 +749,23 @@ func New(cfg *config.Config, log *slog.Logger, devMode bool) (*Application, erro
// Create Code Mode service — wires the three Code Mode VoidLLMDeps functions
// and the OnToolsListHook as methods on a single struct so they share state
// without ad-hoc closure captures.
//
// SchemaTTL is only assigned a default when Code Mode is explicitly enabled,
// so it can still be nil here when Code Mode is disabled. Dereferencing it
// unconditionally would panic at startup; fall back to a zero TTL in that
// case (the service's Code Mode entrypoints are not reachable anyway).
var schemaTTL time.Duration
if cfg.Settings.MCP.CodeMode.SchemaTTL != nil {
schemaTTL = *cfg.Settings.MCP.CodeMode.SchemaTTL
}
cmService := &codeModeService{
executor: adminHandler.CodeExecutor,
toolCache: adminHandler.ToolCache,
callMCPTool: adminHandler.CallMCPTool,
db: database,
log: log,
maxToolCalls: cfg.Settings.MCP.CodeMode.MaxToolCalls,
schemaTTL: *cfg.Settings.MCP.CodeMode.SchemaTTL,
schemaTTL: schemaTTL,
serverCache: mcpServerCache,
codePool: adminHandler.CodePool,
}
Expand Down
30 changes: 30 additions & 0 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,36 @@ func TestSetDefaults_SchemaTTL_ExplicitZeroIsPreserved(t *testing.T) {
}
}

// TestSetDefaults_SchemaTTL_NilWhenCodeModeDisabled verifies that setDefaults
// does NOT fill in a SchemaTTL default when Code Mode is not enabled. The
// pointer stays nil, so any consumer that dereferences it (e.g. app.New) must
// guard against nil; see the regression for the startup panic in
// internal/app/app.go.
func TestSetDefaults_SchemaTTL_NilWhenCodeModeDisabled(t *testing.T) {
t.Parallel()

yaml := `
server:
proxy:
port: 8080
database:
driver: sqlite
dsn: voidllm.db
settings:
encryption_key: aaaaaaaaaaaaaaaa
usage:
buffer_size: 100
`
path := writeTemp(t, "voidllm.yaml", yaml)
cfg, _, err := config.Load(path)
if err != nil {
t.Fatalf("Load() unexpected error: %v", err)
}
if cfg.Settings.MCP.CodeMode.SchemaTTL != nil {
t.Errorf("SchemaTTL = %v, want nil when Code Mode is disabled", *cfg.Settings.MCP.CodeMode.SchemaTTL)
}
}

// ---- Load — full integration -----------------------------------------------

func TestLoad_FullConfig(t *testing.T) {
Expand Down
Loading