Dokploy/dokploy · error · Error
Failed to fetch models: ${errorText}
Error message
Failed to fetch models: ${errorText} What it means
Thrown after a successful Docker removal attempt when the database DELETE on the network table returns no row — i.e. no network row with that networkId exists. NOT_FOUND (not the Docker errors above), and thrown only when .returning() is empty.
Source
Thrown at apps/dokploy/server/api/routers/ai.ts:138
{
id: "MiniMax-M2.7",
object: "model",
created: Date.now(),
owned_by: "minimax",
},
] as Model[];
default:
if (!input.apiKey)
throw new TRPCError({
code: "BAD_REQUEST",
message: "API key must contain at least 1 character(s)",
});
response = await fetch(`${input.apiUrl}/models`, { headers });
}
if (!response.ok) {
const errorText = await response.text();
throw new Error(`Failed to fetch models: ${errorText}`);
}
const res = await response.json();
if (Array.isArray(res)) {
return res.map((model) => ({
id: model.id || model.name,
object: "model",
created: Date.now(),
owned_by: "provider",
}));
}
if (res.models) {
return res.models.map((model: any) => ({
id: model.id || model.name,
object: "model",
created: Date.now(),View on GitHub (pinned to 546686ea35)
Solutions
- Treat a 404 NOT_FOUND from removeNetwork as idempotent success if the goal is deletion
- Refresh the network list in the client after deletion to avoid replaying stale IDs
- Guard against double-submission in the UI (disable button while pending)
- If it persists, confirm the networkId being sent matches an existing row
Example fix
// before
await api.network.remove.mutate(id);
// after
try {
await api.network.remove.mutate(id);
} catch (e) {
if (e?.data?.code === 'NOT_FOUND') return; // already deleted
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
const exists = await db.query.networks.findFirst({
where: eq(network.networkId, id),
});
if (!exists) return; // nothing to do Try / catch
try { await removeNetwork(id); } catch (e) { if (e?.data?.code === 'NOT_FOUND') return; throw e; } Prevention
- Make delete calls idempotent by treating NOT_FOUND as success
- Disable delete buttons while a request is pending
- Refetch the list after every mutation
When it happens
Trigger: Calling removeNetwork twice in a row (second call finds no row); deleting a network whose DB row was already removed; passing a stale or wrong networkId; concurrent deletion racing this call.
Common situations: UI retry after a timeout where the first request actually succeeded; duplicated delete buttons firing; state desync between client cache and server.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
AI-assisted analysis of Dokploy/dokploy@546686ea35 (2026-08-27).
Data as JSON: /api/errors/c7afdd3881807b4c.
Report an issue: GitHub.