fix(cli): skip Kilo model catalog resolution when indexing is disabled

Return early from model() when indexing is disabled so a disabled Kilo config no longer resolves the embedding model catalog (and its baseUrl) or surfaces a model-validation error. Adds a regression test asserting a disabled config with an invalid kilo.baseUrl reaches Disabled without calling fetch.
This commit is contained in:
Rakshith N
2026-07-13 17:35:28 +05:30
parent c550475d67
commit 3698df1bc3
2 changed files with 36 additions and 2 deletions
+2 -2
View File
@@ -94,14 +94,14 @@ function enrichKilo(input: ReturnType<typeof toIndexingConfigInput>, auth: KiloI
}
async function model(input: ReturnType<typeof toIndexingConfigInput>, auth: KiloIndexingAuth) {
if (input.embedderProvider !== "kilo") return input
if (input.embedderProvider !== "kilo" || !input.enabled) return input
const catalog = await fetchKiloEmbeddingModelCatalog({ baseURL: auth.baseUrl, token: auth.apiKey })
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 && input.enabled !== false) {
if (catalog.models.length > 0 && !chosen) {
throw new IndexingModelError({ model: input.modelId })
}
if (chosen) {
@@ -568,6 +568,40 @@ describe("indexing startup degradation", () => {
}
})
test("disabled indexing does not resolve the Kilo model catalog", async () => {
const fetchSpy = spyOn(globalThis, "fetch")
const key = process.env.KILO_API_KEY
const config: Partial<Config.Info> = {
...staleKilo,
indexing: {
...staleKilo.indexing,
enabled: false,
model: "removed/model",
kilo: { baseUrl: "not a url" },
},
}
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")
expect(fetchSpy).not.toHaveBeenCalled()
},
})
} finally {
if (key === undefined) delete process.env.KILO_API_KEY
else process.env.KILO_API_KEY = key
fetchSpy.mockRestore()
}
})
test("does not allocate an engine when indexing configuration is disabled", async () => {
const created: string[] = []
IndexingWorker.override((directory, root, hooks) => {