{"record":{"id":"571a3f7d071910c7","repo":"siyuan-note/siyuan","slug":"window-siyuan-languages-kernel-28-or-server-pro","errorCode":null,"errorMessage":"window.siyuan.languages._kernel[28] (or server-provided data.msg/data.message)","messagePattern":"window\\.siyuan\\.languages\\._kernel\\[28\\] \\(or server-provided data\\.msg/data\\.message\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"app/src/ai/editorSSE.ts","lineNumber":110,"sourceCode":"    onEvent: (event: TAIEditorSSEEvent) => void,\n    signal: AbortSignal,\n) => {\n    const response = await fetch(\"/api/ai/editor/chat\", {\n        method: \"POST\",\n        headers: {\"Content-Type\": \"application/json\"},\n        body: JSON.stringify(request),\n        signal,\n    });\n    const contentType = response.headers.get(\"Content-Type\") || \"\";\n    if (!response.ok || !contentType.includes(\"text/event-stream\")) {\n        let message = window.siyuan.languages._kernel[28];\n        try {\n            const data = await response.json();\n            message = data?.msg || data?.message || message;\n        } catch (e) {\n            // 响应不是 JSON 时使用统一错误文案。\n        }\n        throw new Error(message);\n    }\n    const reader = response.body?.getReader();\n    if (!reader) {\n        throw new Error(window.siyuan.languages._kernel[28]);\n    }\n    const decoder = new TextDecoder();\n    const parserState = createAIEditorSSEParserState();\n    let terminalReceived = false;\n    while (true) {\n        const result = await reader.read();\n        if (result.done) {\n            break;\n        }\n        parseAIEditorSSE(parserState, decoder.decode(result.value, {stream: true})).forEach(event => {\n            terminalReceived = terminalReceived || event.type === \"done\" || event.type === \"error\";\n            onEvent(event);\n        });\n    }","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/app/src/ai/editorSSE.ts#L92-L128","documentation":"Thrown by fetchAIEditorSSE when the POST to /api/ai/editor/chat either returns a non-2xx status or does not answer with Content-Type text/event-stream. The kernel rejected the AI chat request (auth, configuration, or server-side failure), so the SSE stream cannot be opened. The displayed text is the server-provided data.msg/data.message when the body is JSON, otherwise the localized kernel fallback at window.siyuan.languages._kernel[28].","triggerScenarios":"Thrown at app/src/ai/editorSSE.ts:110 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that the AI provider is configured and the access token is valid in Settings - AI","Verify the kernel is running and the endpoint /api/ai/editor/chat returns 200 with an event-stream content type","Inspect the JSON body of the failed response; its msg or message field overrides the generic text","Reproduce the request with curl to see the raw status code and body"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}