Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: keep saving a provider with no fallback, which the preset-only fallbackProvider rule started rejecting

[._.]/ Adam Eivy3c4d32d6745f
diff --git a/server/lib/aiToolkit/validation.js b/server/lib/aiToolkit/validation.js
index d0912184e4..d0b7f45f68 100644
--- a/server/lib/aiToolkit/validation.js
+++ b/server/lib/aiToolkit/validation.js
@@ -108,8 +108,11 @@ export const providerSchema = z.object({
heavyModel: z.string().nullable().optional(),
ultraModel: z.string().nullable().optional(),
// PRESET-ONLY: the fallback chain reads `providers[fallbackProvider]` off the
- // stored map, where a composite never exists (#7564).
- fallbackProvider: z.string().regex(PRESET_ID_RE, PRESET_ONLY_MESSAGE).max(80).nullable().optional(),
+ // stored map, where a composite never exists (#7564). `''` stays accepted: it is
+ // the picker's "None (use system default)" sentinel, and ProviderForm spreads
+ // the whole form into the body, so EVERY provider saved without a fallback
+ // sends it. Refine rather than a union so the refusal keeps naming the rule.
+ fallbackProvider: z.string().max(80).refine((value) => value === '' || PRESET_ID_RE.test(value), PRESET_ONLY_MESSAGE).nullable().optional(),
// Model to run on the fallback provider. The UI sends '' when no model is
// pinned (fall back to the fallback provider's own default), so allow empty.
fallbackModel: z.string().nullable().optional(),
diff --git a/server/lib/validation.providerRef.test.js b/server/lib/validation.providerRef.test.js
index 1e8109f783..cd6c55a257 100644
--- a/server/lib/validation.providerRef.test.js
+++ b/server/lib/validation.providerRef.test.js
@@ -15,7 +15,7 @@ import {
runSchema,
} from './validation.js';
import { createCosTaskSchema, createTaskTemplateSchema, updateTaskTemplateSchema } from './cosValidation.js';
-import { providerActiveSchema, providerSchema, runSchema as toolkitRunSchema } from './aiToolkit/validation.js';
+import { providerActiveSchema, providerCreateSchema, providerSchema, runSchema as toolkitRunSchema } from './aiToolkit/validation.js';
const ACCEPTED = ['claude-code', 'pi.tui@nvidia-nim-free', 'claude.cli@anthropic+corp-auth', 'direct.api@ollama'];
const REJECTED = ['pi.tui@Nvidia', 'pi.tui@', 'pi.gui@x', 'direct.api@ollama+corp-auth', '__proto__'];
@@ -73,6 +73,11 @@ describe('preset-only surfaces refuse a composite and name the rule', () => {
const result = providerSchema.safeParse({ ...base, fallbackProvider: 'pi.tui@nvidia-nim' });
expect(result.success).toBe(false);
expect(message(result)).toMatch(/preset provider id/);
+ // '' is the picker's "None (use system default)" option, and ProviderForm
+ // spreads the whole form into the body — so tightening this field to the
+ // preset grammar must not 400 every provider saved without a fallback.
+ expect(providerSchema.safeParse({ ...base, fallbackProvider: '' }).success).toBe(true);
+ expect(providerCreateSchema.safeParse({ ...base, fallbackProvider: '' }).success).toBe(true);
});
it("an app's taskTypeOverrides pin", () => {