Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): return null for a model_in_use impact with no references (R1-L1)
Diego Zacariasff79d97175d0
diff --git a/control-ui/lib/__tests__/llmModelsApi.test.ts b/control-ui/lib/__tests__/llmModelsApi.test.tsindex 22ed12b20..4038778fa 100644--- a/control-ui/lib/__tests__/llmModelsApi.test.ts+++ b/control-ui/lib/__tests__/llmModelsApi.test.ts@@ -206,6 +206,33 @@ describe('disable/delete impact gate (?force)', () => {expect(getModelInUseImpact(err)).toBeNull()}})++ it('getModelInUseImpact returns null when the impact carries no references', async () => {+ // A model_in_use 409 whose impact resolves to zero Host/grant references+ // must fall through to the generic error banner, not open a "still in use"+ // confirm with an empty reference list (parity with the sibling helpers).+ vi.spyOn(globalThis, 'fetch').mockResolvedValue(+ jsonResponse(+ {+ error: 'model_in_use',+ message: 'still referenced',+ impact: {+ provider: 'claude',+ model: 'claude-haiku-4-5',+ hostsAffected: [],+ grantsAffected: [],+ },+ },+ 409+ )+ )+ try {+ await deleteLlmModel(SAMPLE.id)+ expect.unreachable('deleteLlmModel should reject on 409')+ } catch (err) {+ expect(getModelInUseImpact(err)).toBeNull()+ }+ })})describe('getAdminAttention', () => {diff --git a/control-ui/lib/api.ts b/control-ui/lib/api.tsindex 8333d651a..e657b7f3c 100644--- a/control-ui/lib/api.ts+++ b/control-ui/lib/api.ts@@ -1828,11 +1828,17 @@ export function getModelInUseImpact(err: unknown): ModelInUseImpact | null {const impact = body.impactif (!impact || typeof impact !== 'object') return nullconst rec = impact as Record<string, unknown>+ const hostsAffected = coerceModelHostReferences(rec.hostsAffected)+ const grantsAffected = coerceModelGrantReferences(rec.grantsAffected)+ // A matched code with an empty/malformed impact would open the "still in use"+ // confirm with no references to show — fall through to the generic error+ // banner instead, matching getBudgetsUsingPrice/getUnpricedModelsError.+ if (hostsAffected.length === 0 && grantsAffected.length === 0) return nullreturn {provider: typeof rec.provider === 'string' ? rec.provider : '',model: typeof rec.model === 'string' ? rec.model : '',- hostsAffected: coerceModelHostReferences(rec.hostsAffected),- grantsAffected: coerceModelGrantReferences(rec.grantsAffected),+ hostsAffected,+ grantsAffected,}}diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex ce8768032..51480167a 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.423",+ "version": "0.1.424","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.423",+ "version": "0.1.424","dependencies": {"@clerum/llm-providers": "file:../packages/llm-providers","@clerum/workflow-recipe-capability-policy": "file:../packages/workflow-recipe-capability-policy",diff --git a/control-ui/package.json b/control-ui/package.jsonindex 653ecf0fd..180be428b 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.423",+ "version": "0.1.424","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",