From 40a39b2d14282fd9ca9bd585c6ba583efc990fe9 Mon Sep 17 00:00:00 2001 From: William Mantly Date: Mon, 20 Jul 2026 11:55:41 -0400 Subject: [PATCH] Add Ollama/organize logging to debug 403 filing failures - Log raw Ollama HTTP body on non-2xx responses - Log JSON extraction failures with raw content - Log organizeWatcher tick errors instead of swallowing them Signed-off-by: William Mantly --- controller/ollama.js | 14 ++++++++++++-- controller/organizeWatcher.js | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/controller/ollama.js b/controller/ollama.js index abebe3b..60b169c 100644 --- a/controller/ollama.js +++ b/controller/ollama.js @@ -7,8 +7,16 @@ function extractJSON(content){ let text = String(content).replace(/```json/gi, '').replace(/```/g, '').trim(); let start = text.indexOf('{'); let end = text.lastIndexOf('}'); - if(start === -1 || end === -1) throw new Error('No JSON in model response'); - return JSON.parse(text.slice(start, end + 1)); + if(start === -1 || end === -1){ + console.error('extractJSON: no JSON object found in:', content); + throw new Error('No JSON in model response'); + } + try{ + return JSON.parse(text.slice(start, end + 1)); + }catch(error){ + console.error('extractJSON: parse failed. extracted:', text.slice(start, end + 1)); + throw error; + } } // One-shot JSON chat against the Ollama cloud model. @@ -30,6 +38,8 @@ async function chatJSON(system, user){ }), }); if(!res.ok){ + let body = await res.text().catch(() => ''); + console.error(`Ollama chat failed (${res.status}):`, body.slice(0, 500)); let error = new Error('OllamaError'); error.message = `Ollama chat failed( ${res.status})`; error.status = 502; diff --git a/controller/organizeWatcher.js b/controller/organizeWatcher.js index 48f063e..48eda28 100644 --- a/controller/organizeWatcher.js +++ b/controller/organizeWatcher.js @@ -31,6 +31,8 @@ async function tick(){ } }catch(error){ // Transmission down / transient — just try again next tick. + console.error('organizeWatcher tick failed:', error.name, error.message); + if(error.stack) console.error(error.stack); }finally{ lock = false; }