{"record":{"id":"3d51e4c0c45bb971","repo":"BookStackApp/BookStack","slug":"not-an-image-file-3d51e4","errorCode":null,"errorMessage":"Not an image file","messagePattern":"Not an image file","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"resources/js/wysiwyg-tinymce/drop-paste-handling.js","lineNumber":17,"sourceCode":"import {Clipboard} from '../services/clipboard.ts';\n\nlet wrap;\nlet draggedContentEditable;\n\nfunction hasTextContent(node) {\n    return node && !!(node.textContent || node.innerText);\n}\n\n/**\n * Upload an image file to the server\n * @param {File} file\n * @param {int} pageId\n */\nasync function uploadImageFile(file, pageId) {\n    if (file === null || file.type.indexOf('image') !== 0) {\n        throw new Error('Not an image file');\n    }\n\n    const remoteFilename = file.name || `image-${Date.now()}.png`;\n    const formData = new FormData();\n    formData.append('file', file, remoteFilename);\n    formData.append('uploaded_to', pageId);\n\n    const resp = await window.$http.post(window.baseUrl('/images/gallery'), formData);\n    return resp.data;\n}\n\n/**\n * Handle pasting images from clipboard.\n * @param {Editor} editor\n * @param {WysiwygConfigOptions} options\n * @param {ClipboardEvent|DragEvent} event\n */\nfunction paste(editor, options, event) {","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/BookStackApp/BookStack/blob/18f8469a1c72f8cc8497e9372635e6dea5028071/resources/js/wysiwyg-tinymce/drop-paste-handling.js#L1-L35","documentation":"Guard in the legacy TinyMCE editor's uploadImageFile rejecting a File that is null or has a non-image MIME type, so paste/drop handling only uploads actual images. Input at fault: the pasted or dropped file whose type does not start with 'image'.","triggerScenarios":"Thrown at resources/js/wysiwyg-tinymce/drop-paste-handling.js:17 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check file.type starts with 'image' before calling uploadImageFile","Notify the user that only image files can be pasted/dropped as images","Handle empty browser file.type with an extension-based fallback check"],"exampleFix":null,"handlingStrategy":"type-guard","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"}