diegosouzapw/OmniRoute · error · Error

errorData.error?.message || t("failedSaveCustomModel")

Error message

errorData.error?.message || t("failedSaveCustomModel")

What it means

Thrown when POST /api/provider-models fails to persist a manually added compatible model. errorData.error.message carries the API's validation or DB error; the t("failedSaveCustomModel") fallback fires when the body has no structured error.

Solutions

  1. Check the modelId format matches the provider's expectations
  2. Retry the save; transient DB locks can reject writes
  3. Inspect /api/provider-models logs for the Zod validation failure
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/app/(dashboard)/dashboard/providers/[id]/components/CompatibleModelsSection.tsx:290 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/71d34d00b8c7c8d1. Report an issue: GitHub.

Appendix: source

Thrown at src/app/(dashboard)/dashboard/providers/[id]/components/CompatibleModelsSection.tsx:290

      const customModelRes = await fetch("/api/provider-models", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({
          provider: providerStorageAlias,
          modelId,
          modelName: modelId,
          source: "manual",
        }),
      });

      if (!customModelRes.ok) {
        let errorData: { error?: { message?: string } } = {};
        try {
          errorData = await customModelRes.json();
        } catch (jsonError) {
          console.error("Failed to parse error response from custom model API:", jsonError);
        }
        throw new Error(errorData.error?.message || t("failedSaveCustomModel"));
      }

      // Only create alias after customModel is saved successfully
      await onSetAlias(modelId, resolvedAlias, providerStorageAlias);
      setNewModel("");
      notify.success(t("modelAddedSuccess", { modelId }));
      onModelsChanged?.();
    } catch (error) {
      console.error("Error adding model:", error);
      notify.error(error instanceof Error ? error.message : t("failedAddModelTryAgain"));
    } finally {
      setAdding(false);
    }
  };

  const handleImport = async () => {
    if (!allowImport || importing) return;
    const activeConnection = connections.find((conn) => conn.isActive !== false);

View on GitHub (pinned to a179ffed5b)