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: reject array diagnostics to match object-guard convention (#2328)

Adam Eivyf8b8315dd4fb
diff --git a/server/services/cosTaskStore.js b/server/services/cosTaskStore.js
index 977b3ad04f..31283d6307 100644
--- a/server/services/cosTaskStore.js
+++ b/server/services/cosTaskStore.js
@@ -277,8 +277,8 @@ export async function addTask(taskData, taskType = 'user', { raw = false, ignore
// was silently dropped. Persist it as first-class metadata so downstream
// telemetry can aggregate auto-fix outcomes by tier / category / failure reason.
// It round-trips through the markdown store via the JSON sentinel (see
- // taskParser.js escapeNewlines). A non-object (defensive) is ignored.
- if (taskData.diagnostics && typeof taskData.diagnostics === 'object') {
+ // taskParser.js escapeNewlines). A non-object / array (defensive) is ignored.
+ if (taskData.diagnostics && typeof taskData.diagnostics === 'object' && !Array.isArray(taskData.diagnostics)) {
metadata.diagnostics = taskData.diagnostics;
}
// Content-edit timestamp for cross-peer newest-edit-wins LWW (#1714). Stamped
diff --git a/server/services/cosTaskStore.test.js b/server/services/cosTaskStore.test.js
index 8e4cf74971..9f8bb3b8ac 100644
--- a/server/services/cosTaskStore.test.js
+++ b/server/services/cosTaskStore.test.js
@@ -183,11 +183,13 @@ describe('cosTaskStore.addTask', () => {
expect(reloaded.metadata.diagnostics).toEqual(diagnostics);
});
- it('omits diagnostics metadata when none is supplied and ignores a non-object value', async () => {
+ it('omits diagnostics metadata when none is supplied and ignores a non-object / array value', async () => {
const created = await addTask({ description: 'no diagnostics here' }, 'user');
expect(created.metadata.diagnostics).toBeUndefined();
const bad = await addTask({ description: 'bad diagnostics', diagnostics: 'not-an-object' }, 'user');
expect(bad.metadata.diagnostics).toBeUndefined();
+ const arr = await addTask({ description: 'array diagnostics', diagnostics: ['nope'] }, 'user');
+ expect(arr.metadata.diagnostics).toBeUndefined();
});
it('rejects a duplicate with the same first-line description and app scope', async () => {