{"record":{"id":"3204c47fec2874fe","repo":"BigPizzaV3/CodexPlusPlus","slug":"api-3204c4","errorCode":null,"errorMessage":"API 未能生成本批整理结果","messagePattern":"API 未能生成本批整理结果","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"tools/conversation-canvas/public/canvas.user.js","lineNumber":698,"sourceCode":"      size+=part.value.byteLength;if(size>4*1024*1024)throw Object.assign(Error('API 响应超过大小限制'),{canvasApiLocal:true});\n      const text=decoder.decode(part.value,{stream:true});\n      if(!sse){raw+=text;if(/^\\s*(data:|:)/.test(raw)){sse=true;buffer=raw;raw='';}}\n      else buffer+=text;\n      if(sse){let end;while((end=buffer.indexOf('\\n'))>=0){consume(buffer.slice(0,end).replace(/\\r$/,''));buffer=buffer.slice(end+1);}}\n      progress({bytes:size,chars:content.length});if(done)break;\n    }\n    const tail=decoder.decode();if(sse){buffer+=tail;if(buffer.trim())consume(buffer.replace(/\\r$/,''));\n      if(!done&&!finish)throw Object.assign(Error('API 流式连接提前结束，本批未提交'),{canvasApiLocal:true,retryable:true});\n      return {choices:[{finish_reason:finish,message:{content}}]};\n    }\n    try{return JSON.parse(raw+tail);}catch{throw Object.assign(Error('API 返回的不是 JSON，请检查 API 地址'),{canvasApiLocal:true});}\n  }finally{void reader.cancel().catch(()=>{});try{reader.releaseLock();}catch{}}\n}\n\nfunction completionText(body){\n  const choice=body?.choices?.[0];\n  if(choice?.finish_reason==='length')throw Error('API 输出达到长度上限，本批未提交；请使用输出容量更大的模型');\n  if(choice?.finish_reason==='content_filter'||choice?.message?.refusal)throw Error('API 未能生成本批整理结果');\n  const content=choice?.message?.content;\n  const value=typeof content==='string'?content:Array.isArray(content)?content.filter(p=>p?.type==='text').map(p=>p.text||'').join(''):'';\n  if(!value.trim())throw Error('API 未返回有效的 choices[0].message.content，请确认兼容 Chat Completions');\n  return value;\n}\n\nfunction waitForApi(promise,signal){\n  signal?.throwIfAborted();\n  if(!signal)return promise;\n  return new Promise((resolve,reject)=>{\n    const abort=()=>{signal.removeEventListener('abort',abort);reject(signal.reason||new DOMException('Aborted','AbortError'));};\n    signal.addEventListener('abort',abort,{once:true});\n    promise.then(value=>{signal.removeEventListener('abort',abort);resolve(value);},error=>{signal.removeEventListener('abort',abort);reject(error);});\n  });\n}\n\nfunction createApiOrganizer({request,timeoutMs=300000,maxRetries=2,retryDelayMs=2000}){\n  const requests=new Map();","sourceCodeStart":680,"sourceCodeEnd":716,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/tools/conversation-canvas/public/canvas.user.js#L680-L716","documentation":"completionText() throws this when the provider refused to produce content: finish_reason==='content_filter' or the message carries a refusal field. The batch result is unusable, so the script aborts the batch instead of storing filtered/refused output.","triggerScenarios":"choices[0].finish_reason==='content_filter', or choices[0].message.refusal is set — the provider's safety layer blocked generation.","commonSituations":"Conversation content triggered the provider's content policy; safety settings too strict on the account; certain flagged topics in the messages being organized.","solutions":["Review the conversation content for policy-triggering material","Adjust safety/content-filter settings on the provider account if available","Try a different model or provider with more permissive filtering","Split the batch to isolate and exclude the problematic messages"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const refused = body?.choices?.[0]?.finish_reason==='content_filter' || !!body?.choices?.[0]?.message?.refusal;","typeGuard":null,"tryCatchPattern":"try{ await organizeLong(...) }catch(e){ if(e.message==='API 未能生成本批整理结果'){ notifyContentBlocked(); splitBatchAndExcludeFlagged(); } }","preventionTips":["Know your provider's content policy","Adjust safety settings where available","Split sensitive conversations into smaller batches"],"tags":["api","content-filter","refusal"],"backgroundTag":"api-error-response","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}