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

address review: don't crash suggestion panel when a curated entry has no published versions

Adam Eivydc03ae5cb9cf
diff --git a/server/services/civitaiSuggestions.js b/server/services/civitaiSuggestions.js
index 04df41740a..77923e0e28 100644
--- a/server/services/civitaiSuggestions.js
+++ b/server/services/civitaiSuggestions.js
@@ -14,7 +14,6 @@ import {
fetchCivitaiModel,
normalizeCivitaiImageUrl,
pickPreviewImage,
- pickVersion,
searchCivitaiLoras,
extractSamplePrompt,
} from '../lib/civitai.js';
@@ -41,9 +40,19 @@ const cache = new Map();
// Shape one Civitai model into the lightweight suggestion-card payload the
// /media/loras UI consumes. Defensive: any field can be missing on Civitai.
+// Returns null on any malformed input (no published versions, no installable
+// file, etc.) — the suggestion panel is best-effort, so a single bad entry
+// must not poison the whole list.
const buildCard = (model) => {
if (!model || typeof model !== 'object') return null;
- const version = pickVersion(model, null);
+ // pickVersion throws (ServerError) when modelVersions[] is empty — that's
+ // appropriate for the install path, but here we're building a suggestion
+ // card for a model the user hasn't asked to install yet. A single Civitai
+ // entry that's been unpublished by the creator would otherwise crash the
+ // whole Promise.all in fetchCurated.
+ const versions = Array.isArray(model.modelVersions) ? model.modelVersions : [];
+ if (!versions.length) return null;
+ const version = versions[0];
if (!version) return null;
const file = (() => {
// pickPrimaryFile throws when no .safetensors — for a suggestion card we