From 3382eda18089be0837feaa0214ff5650a2f64ef1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Mar 2026 07:35:22 +0000 Subject: [PATCH] Address code review: improve error handling in loadBrain and preview-deploy - Wrap individual JSON parse calls in try-catch for partial success - Add debug logging for fetch failures instead of silent suppression - Improve preview-deploy.yml copy error reporting Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com> Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/0ee19d81-920c-4a36-a4c4-8238f242afb5 --- .github/workflows/preview-deploy.yml | 12 ++++++++---- docs/index.html | 28 ++++++++++++++-------------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.github/workflows/preview-deploy.yml b/.github/workflows/preview-deploy.yml index aab6924f..b916592e 100644 --- a/.github/workflows/preview-deploy.yml +++ b/.github/workflows/preview-deploy.yml @@ -57,26 +57,30 @@ jobs: # Sync status-board into docs for GitHub Pages access if [ -d "status-board" ]; then mkdir -p docs/status-board - cp -r status-board/* docs/status-board/ 2>/dev/null || true + echo "Copying status-board..." + cp -r status-board/* docs/status-board/ || echo "⚠️ status-board copy had errors" [ -d "docs/status-board/node_modules" ] && rm -rf docs/status-board/node_modules fi # Sync ticket-system if [ -d "ticket-system" ]; then mkdir -p docs/ticket-system - cp -r ticket-system/* docs/ticket-system/ 2>/dev/null || true + echo "Copying ticket-system..." + cp -r ticket-system/* docs/ticket-system/ || echo "⚠️ ticket-system copy had errors" fi # Sync notification if [ -d "notification" ]; then mkdir -p docs/notification - cp -r notification/* docs/notification/ 2>/dev/null || true + echo "Copying notification..." + cp -r notification/* docs/notification/ || echo "⚠️ notification copy had errors" fi # Sync dynamic-comic-studio if [ -d "dynamic-comic-studio" ]; then mkdir -p docs/dynamic-comic-studio - cp -r dynamic-comic-studio/* docs/dynamic-comic-studio/ 2>/dev/null || true + echo "Copying dynamic-comic-studio..." + cp -r dynamic-comic-studio/* docs/dynamic-comic-studio/ || echo "⚠️ dynamic-comic-studio copy had errors" fi # Sync dashboard data diff --git a/docs/index.html b/docs/index.html index e2763a61..579e2d36 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1718,21 +1718,21 @@ function resetAllSettings(){ async function loadBrain(){ try{ const [mr,rr,dr,shr,bbr,fsr,tlr]=await Promise.all([ - fetch(RAW+'/.github/brain/memory.json').catch(()=>null), - fetch(RAW+'/.github/brain/routing-map.json').catch(()=>null), - fetch(RAW+'/.github/persona-brain/dev-status.json').catch(()=>null), - fetch(RAW+'/data/system-health.json').catch(()=>null), - fetch(RAW+'/data/bulletin-board.json').catch(()=>null), - fetch(RAW+'/federation-status.json').catch(()=>null), - fetch(RAW+'/persona-telemetry/latest-summary.json').catch(()=>null), + fetch(RAW+'/.github/brain/memory.json').catch(e=>{console.debug('[Brain] memory fetch failed:',e.message);return null;}), + fetch(RAW+'/.github/brain/routing-map.json').catch(e=>{console.debug('[Brain] routing fetch failed:',e.message);return null;}), + fetch(RAW+'/.github/persona-brain/dev-status.json').catch(e=>{console.debug('[Brain] devStatus fetch failed:',e.message);return null;}), + fetch(RAW+'/data/system-health.json').catch(e=>{console.debug('[Brain] systemHealth fetch failed:',e.message);return null;}), + fetch(RAW+'/data/bulletin-board.json').catch(e=>{console.debug('[Brain] bulletin fetch failed:',e.message);return null;}), + fetch(RAW+'/federation-status.json').catch(e=>{console.debug('[Brain] federation fetch failed:',e.message);return null;}), + fetch(RAW+'/persona-telemetry/latest-summary.json').catch(e=>{console.debug('[Brain] telemetry fetch failed:',e.message);return null;}), ]); - if(mr&&mr.ok) A.brain=await mr.json(); - if(rr&&rr.ok) A.routing=await rr.json(); - if(dr&&dr.ok) A.devStatus=await dr.json(); - if(shr&&shr.ok) A.systemHealth=await shr.json(); - if(bbr&&bbr.ok) A.bulletinBoard=await bbr.json(); - if(fsr&&fsr.ok) A.federationStatus=await fsr.json(); - if(tlr&&tlr.ok) A.telemetrySummary=await tlr.json(); + if(mr&&mr.ok) try{A.brain=await mr.json();}catch(e){console.debug('[Brain] memory parse failed:',e.message);} + if(rr&&rr.ok) try{A.routing=await rr.json();}catch(e){console.debug('[Brain] routing parse failed:',e.message);} + if(dr&&dr.ok) try{A.devStatus=await dr.json();}catch(e){console.debug('[Brain] devStatus parse failed:',e.message);} + if(shr&&shr.ok) try{A.systemHealth=await shr.json();}catch(e){console.debug('[Brain] systemHealth parse failed:',e.message);} + if(bbr&&bbr.ok) try{A.bulletinBoard=await bbr.json();}catch(e){console.debug('[Brain] bulletin parse failed:',e.message);} + if(fsr&&fsr.ok) try{A.federationStatus=await fsr.json();}catch(e){console.debug('[Brain] federation parse failed:',e.message);} + if(tlr&&tlr.ok) try{A.telemetrySummary=await tlr.json();}catch(e){console.debug('[Brain] telemetry parse failed:',e.message);} }catch(_){} if(!A.brain) A.brain={...FB_BRAIN}; updBbar();