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([issue-709]): harden goal-option gathering against malformed goals

[._.]/ Adam Eivy1c68d3d8061e
diff --git a/server/services/reviewQueue.js b/server/services/reviewQueue.js
index 9a0b2e8188..9bffca7317 100644
--- a/server/services/reviewQueue.js
+++ b/server/services/reviewQueue.js
@@ -68,9 +68,13 @@ async function getActiveGoalOptions() {
return null;
});
const goals = Array.isArray(data?.goals) ? data.goals : [];
+ // Guard each entry — a malformed `null`/non-object goal would otherwise throw
+ // on `g.status` here, and because this runs *before* the per-producer
+ // Promise.all catch in buildQueue, that throw would sink the whole queue
+ // rather than degrading goal targets to empty.
return goals
- .filter((g) => g.status === 'active' && typeof g.id === 'string' && g.id)
- .map((g) => ({ id: g.id, title: g.title || '(untitled goal)' }));
+ .filter((g) => g && typeof g === 'object' && g.status === 'active' && typeof g.id === 'string' && g.id)
+ .map((g) => ({ id: g.id, title: typeof g.title === 'string' && g.title ? g.title : '(untitled goal)' }));
}
/**
@@ -116,11 +120,12 @@ const PRODUCERS = [
source: 'ask',
label: 'Ask answers',
drillTo: '/ask',
- // No inline action: "promote" for an Ask answer means saving a specific turn
- // into Brain/Task/Goal (askConversations.promoteAskTurn), which needs the
- // user to pick a target — so it can't be one-click. (setPromoted only *pins*
- // the conversation against expiry, which the Ask UI labels "Pin", not the
- // promote-to-target the queue title implies.) Drill into /ask to promote.
+ // Ask carries no single `action`/`resolve` primitive (the row's
+ // `setPromoted` only *pins* the conversation against expiry, which the Ask
+ // UI labels "Pin", not promote-to-target). Promotion is instead offered
+ // inline via `promoteTargets` + `goalOptions`: brain/task in one click and
+ // goal via a picker (see map() below). Drilling into /ask still works for a
+ // per-turn promote the queue's latest-turn shortcut doesn't cover.
async gather() {
// Conversations with content that haven't been promoted to brain/task/goal.
const convs = await askConversations.listConversations({ limit: PER_SOURCE_LIMIT * 2 });
diff --git a/server/services/reviewQueue.test.js b/server/services/reviewQueue.test.js
index 74982812e9..cda1bd69b8 100644
--- a/server/services/reviewQueue.test.js
+++ b/server/services/reviewQueue.test.js
@@ -245,6 +245,18 @@ describe('reviewQueue.buildQueue', () => {
expect(ask.promoteTargets).toEqual(['brain', 'task']);
expect(ask.goalOptions).toBeUndefined();
});
+
+ it('skips malformed goal entries without sinking the whole queue', async () => {
+ askConversations.listConversations.mockResolvedValue([{ id: 'a1', title: 'promote me', promoted: false, turnCount: 1 }]);
+ // A null / non-object entry must not throw synchronously in the filter —
+ // that would run before the per-producer catch and sink every source.
+ identity.getGoals.mockResolvedValue({ goals: [null, 'bogus', { id: 'g1', title: 'Real goal', status: 'active' }] });
+ const queue = await buildQueue();
+ const ask = queue.items.find(i => i.source === 'ask');
+ expect(ask).toBeTruthy();
+ expect(ask.promoteTargets).toEqual(['brain', 'task', 'goal']);
+ expect(ask.goalOptions).toEqual([{ id: 'g1', title: 'Real goal' }]);
+ });
});
describe('reviewQueue.promoteAskQueueItem', () => {