{"record":{"id":"877f009df736257c","repo":"BookStackApp/BookStack","slug":"failed-to-save-image-with-error-err","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/utils/diagrams.ts","lineNumber":60,"sourceCode":"    }\n\n    try {\n        const img = await DrawIO.upload(pngData, context.options.pageId);\n        context.editor.update(() => {\n            node.setDrawingIdAndUrl(String(img.id), img.url);\n        });\n    } catch (err) {\n        if (err instanceof HttpError) {\n            handleUploadError(err, context);\n        }\n\n        if (isNew) {\n            context.editor.update(() => {\n                node.remove();\n            });\n        }\n\n        throw new Error(`Failed to save image with error: ${err}`);\n    }\n}\n\nexport function $openDrawingEditorForNode(context: EditorUiContext, node: DiagramNode): void {\n    let isNew = false;\n    DrawIO.show(context.options.drawioUrl, async () => {\n        const drawingId = await loadDiagramIdFromNode(context.editor, node);\n        isNew = !drawingId;\n        return isNew ? '' : DrawIO.load(drawingId);\n    }, async (pngData: string) => {\n        return updateDrawingNodeFromData(context, node, pngData, isNew);\n    });\n}\n\nexport function showDiagramManager(callback: (image: EditorImageData) => any) {\n    const imageManager: ImageManager = window.$components.first('image-manager') as ImageManager;\n    imageManager.show((image: EditorImageData) => {\n        callback(image);","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/BookStackApp/BookStack/blob/18f8469a1c72f8cc8497e9372635e6dea5028071/resources/js/wysiwyg/utils/diagrams.ts#L42-L78","documentation":"Wrapping error thrown in updateDrawingNodeFromData when saving the rendered diagram PNG via DrawIO.upload fails; HttpError upload failures are surfaced to the user first (handleUploadError), then the error is rethrown with the cause embedded. Root causes are network/server errors or a new-node cleanup path after failed upload.","triggerScenarios":"Thrown at resources/js/wysiwyg/utils/diagrams.ts:60 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check network connectivity and server image-upload endpoint availability","Inspect the embedded err for the underlying HttpError status","Verify upload file-size limits and CSRF/auth state on the server","Retry saving the drawing after resolving the transport issue"],"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"}