fix(cli): skip indexing model validation when disabled

A disabled Kilo indexing config with an invalid explicit model previously threw IndexingModelError and surfaced an Error status, bypassing the disabled branch. Guard the throw with input.enabled so disabled configs are reported as Disabled as before.
This commit is contained in:
Rakshith N
2026-07-12 00:39:15 +05:30
parent ad2cc712d0
commit bb4a71d9d4
2 changed files with 44 additions and 1 deletions
+1 -1
View File
@@ -101,7 +101,7 @@ async function model(input: ReturnType<typeof toIndexingConfigInput>, auth: Kilo
if (input.modelId) {
const id = catalog.aliases[input.modelId] ?? input.modelId
const chosen = catalog.models.find((item) => item.id === id)
if (catalog.models.length > 0 && !chosen) {
if (catalog.models.length > 0 && !chosen && input.enabled !== false) {
throw new IndexingModelError({ model: input.modelId })
}
if (chosen) {
@@ -525,6 +525,49 @@ describe("indexing startup degradation", () => {
})
})
test("does not validate the indexing model when indexing is disabled", async () => {
global.fetch = (() =>
Promise.resolve(
new Response(
JSON.stringify({
defaultModel: "mistralai/mistral-embed-2312",
models: [
{ id: "mistralai/mistral-embed-2312", name: "Mistral Embed 2312", dimension: 1024, scoreThreshold: 0.35 },
],
aliases: {},
}),
),
)) as unknown as typeof global.fetch
const logger = Log.create({ service: "kilocode-indexing" })
const warn = spyOn(logger, "warn")
const key = process.env.KILO_API_KEY
const config: Partial<Config.Info> = {
...staleKilo,
indexing: { ...staleKilo.indexing, enabled: false, model: "removed/model" },
}
await using tmp = await tmpdir({ git: true, config })
process.env["KILO_CONFIG_DIR"] = tmp.path
process.env.KILO_API_KEY = "kilo-token"
try {
await provideTestInstance({
directory: tmp.path,
init: Effect.promise(() => KiloIndexing.init()),
fn: async () => {
const status = await wait(() => KiloIndexing.current(), "Disabled")
expect(status.state).toBe("Disabled")
const modelErr = warn.mock.calls.find((call) => IndexingModelError.isInstance(call[1]?.err))?.[1]?.err
expect(modelErr).toBeUndefined()
},
})
} finally {
if (key === undefined) delete process.env.KILO_API_KEY
else process.env.KILO_API_KEY = key
warn.mockRestore()
}
})
test("does not allocate an engine when indexing configuration is disabled", async () => {
const created: string[] = []
IndexingWorker.override((directory, root, hooks) => {