{"record":{"id":"5862a6d3c865ba1b","repo":"SillyTavern/SillyTavern","slug":"failed-to-import-world-info-result-statustext","errorCode":null,"errorMessage":"Failed to import world info: ${result.statusText}","messagePattern":"Failed to import world info: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"public/scripts/world-info.js","lineNumber":5793,"sourceCode":"    }\n\n    const worldName = file.name.substr(0, file.name.lastIndexOf('.'));\n    const sanitizedWorldName = await getSanitizedFilename(worldName);\n    const allowed = await checkOverwriteExistingData('World Info', world_names, sanitizedWorldName, { interactive: true, actionName: 'Import', deleteAction: (existingName) => deleteWorldInfo(existingName) });\n    if (!allowed) {\n        return false;\n    }\n\n    try {\n        const result = await fetch('/api/worldinfo/import', {\n            method: 'POST',\n            headers: getRequestHeaders({ omitContentType: true }),\n            body: formData,\n            cache: 'no-cache',\n        });\n\n        if (!result.ok) {\n            throw new Error(`Failed to import world info: ${result.statusText}`);\n        }\n\n        const data = await result.json();\n\n        if (data.name) {\n            await updateWorldInfoList();\n\n            const newIndex = world_names.indexOf(data.name);\n            if (newIndex >= 0) {\n                $('#world_editor_select').val(newIndex).trigger('change');\n            }\n\n            toastr.success(t`World Info \"${data.name}\" imported successfully!`);\n        }\n    } catch (error) {\n        console.error('Error importing world info:', error);\n        toastr.error(t`Failed to import World Info`);\n    }","sourceCodeStart":5775,"sourceCodeEnd":5811,"githubUrl":"https://github.com/SillyTavern/SillyTavern/blob/8172dcd0ee672d3cd9a5e5f7af134f91a45cd2b8/public/scripts/world-info.js#L5775-L5811","documentation":"Thrown when the POST to `/api/worldinfo/import` (multipart/form-data upload of a world-info file) returns a non-OK HTTP status. `result.statusText` is appended so the server's reason (e.g. 'Bad Request', 'Internal Server Error') surfaces to the user. On success the handler reads `data.name` and refreshes the world list.","triggerScenarios":"Uploading a world-info JSON/file via the import flow when the server rejects the payload — malformed JSON, oversized body, missing form field, I/O error writing to the worlds directory, or a name collision the server won't auto-resolve.","commonSituations":"Importing a corrupted or hand-edited .json world file; hitting an Express body-size limit; read-only or permission-denied `worlds/` data folder; importing a file whose name contains characters the filesystem rejects.","solutions":["Open the world-info file locally and validate it is well-formed JSON with the expected entry schema.","Check the server console for the matching 4xx/5xx and its detail; fix the flagged field (often a duplicate name or schema violation).","Verify the `worlds` directory is writable and not full, then retry the import."],"exampleFix":"null","handlingStrategy":"validation","validationCode":"function isValidWorldInfoJson(text) {\n    try {\n        const obj = JSON.parse(text);\n    } catch {\n        return false;\n    }\n    return true;\n}\n\n// before upload\nif (!isValidWorldInfoJson(await file.text())) {\n    toastr.error('World info file is not valid JSON.');\n    return;\n}","typeGuard":"null","tryCatchPattern":"try {\n    await importWorldInfo(formData);\n} catch (e) {\n    toastr.error(`Import failed: ${e.message}`);\n}","preventionTips":["Validate the file is well-formed JSON before uploading.","Keep world-info files under the server's body-size limit.","Ensure the `worlds` data directory is writable."],"tags":["network","http","world-info","import","api"],"backgroundTag":null,"analyzedSha":"8172dcd0ee672d3cd9a5e5f7af134f91a45cd2b8","analyzedAt":"2026-08-13T07:48:40.832Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}