{"record":{"id":"9f38d0ffbb394127","repo":"BookStackApp/BookStack","slug":"failed-to-save-image-with-error-err-9f38d0","errorCode":null,"errorMessage":"Failed to save image with error: ${err}","messagePattern":"Failed to save image with error: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"resources/js/wysiwyg-tinymce/plugin-drawio.js","lineNumber":60,"sourceCode":"        } else {\n            window.$events.emit('error', options.translations.imageUploadErrorText);\n        }\n        console.error(error);\n    };\n\n    // Handle updating an existing image\n    if (currentNode) {\n        DrawIO.close();\n        const imgElem = currentNode.querySelector('img');\n        try {\n            const img = await DrawIO.upload(pngData, options.pageId);\n            pageEditor.undoManager.transact(() => {\n                pageEditor.dom.setAttrib(imgElem, 'src', img.url);\n                pageEditor.dom.setAttrib(currentNode, 'drawio-diagram', img.id);\n            });\n        } catch (err) {\n            handleUploadError(err);\n            throw new Error(`Failed to save image with error: ${err}`, {cause: err});\n        }\n        return;\n    }\n\n    await wait(5);\n\n    const id = `drawing-${Math.random().toString(16).slice(2)}`;\n    const wrapId = `drawing-wrap-${Math.random().toString(16).slice(2)}`;\n    pageEditor.insertContent(`<div drawio-diagram contenteditable=\"false\" id=\"${wrapId}\"><img src=\"${loadingImage}\" id=\"${id}\"></div>`);\n    DrawIO.close();\n\n    try {\n        const img = await DrawIO.upload(pngData, options.pageId);\n        pageEditor.undoManager.transact(() => {\n            pageEditor.dom.setAttrib(id, 'src', img.url);\n            pageEditor.dom.setAttrib(wrapId, 'drawio-diagram', img.id);\n        });\n    } catch (err) {","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/BookStackApp/BookStack/blob/18f8469a1c72f8cc8497e9372635e6dea5028071/resources/js/wysiwyg-tinymce/plugin-drawio.js#L42-L78","documentation":"Wrapping error thrown in the TinyMCE drawio plugin's updateContent when saving the rendered diagram via DrawIO.upload fails; an image-upload error event is shown to the user and the underlying cause is rethrown embedded in the message. Typically a network or server-side upload failure.","triggerScenarios":"Thrown at resources/js/wysiwyg-tinymce/plugin-drawio.js:60 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check network connectivity and the server's image upload endpoint","Verify upload size limits and authentication/CSRF state","Inspect the embedded err for the underlying failure status","Retry the draw.io save after the transport issue is fixed"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"18f8469a1c72f8cc8497e9372635e6dea5028071","analyzedAt":"2026-09-02T19:49:33.068Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}