{"record":{"id":"e9faedf2e862f63f","repo":"SillyTavern/SillyTavern","slug":"no-script-name-provided","errorCode":null,"errorMessage":"No script name provided.","messagePattern":"No script name provided\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"public/scripts/extensions/regex/index.js","lineNumber":1502,"sourceCode":"    await saveRegexScript(script, index, scriptType);\n    if (script.disabled) {\n        !quiet && toastr.success(t`Regex script '${scriptName}' has been disabled.`);\n    } else {\n        !quiet && toastr.success(t`Regex script '${scriptName}' has been enabled.`);\n    }\n\n    return script.scriptName || '';\n}\n\n/**\n * Performs the import of the regex object.\n * @param {RegexScript} regexScript Input object\n * @param {SCRIPT_TYPES} scriptType The type of script to import as\n */\nasync function onRegexImportObjectChange(regexScript, scriptType) {\n    try {\n        if (!regexScript.scriptName) {\n            throw new Error('No script name provided.');\n        }\n\n        // Assign a new UUID\n        regexScript.id = uuidv4();\n\n        const array = getScriptsByType(scriptType);\n        array.push(regexScript);\n\n        switch (scriptType) {\n            case SCRIPT_TYPES.GLOBAL:\n                // will be handled by saveSettingsDebounced\n                break;\n            case SCRIPT_TYPES.SCOPED:\n                await saveScriptsByType(array, SCRIPT_TYPES.SCOPED);\n                break;\n            case SCRIPT_TYPES.PRESET:\n                await saveScriptsByType(array, SCRIPT_TYPES.PRESET);\n                break;","sourceCodeStart":1484,"sourceCodeEnd":1520,"githubUrl":"https://github.com/SillyTavern/SillyTavern/blob/8172dcd0ee672d3cd9a5e5f7af134f91a45cd2b8/public/scripts/extensions/regex/index.js#L1484-L1520","documentation":"Thrown by onRegexImportObjectChange during regex object import when the incoming regexScript has no scriptName. A script name is required to register the script (it is the user-facing identifier and used for toggling/listing), so an import payload missing it is rejected before a UUID is assigned and the script pushed.","triggerScenarios":"Importing a JSON regex object whose scriptName field is empty/missing; a malformed export file; programmatic import of a partial object.","commonSituations":"Hand-edited regex JSON lacking the name; third-party regex packs with inconsistent schema; converting a find/replace snippet into an import object and forgetting the name.","solutions":["Ensure the import object has a non-empty scriptName: regexScript.scriptName = regexScript.scriptName || 'Imported Script'.","Validate the payload schema before import: assert typeof obj.scriptName === 'string' && obj.scriptName.trim().","If importing from a UI, require the name field and disable import until filled."],"exampleFix":"// before\n{ \"findRegex\": \"/foo/g\", \"replaceString\": \"bar\" }\n\n// after\n{ \"scriptName\": \"Foo to Bar\", \"findRegex\": \"/foo/g\", \"replaceString\": \"bar\" }","handlingStrategy":"validation","validationCode":"if (typeof regexScript.scriptName !== 'string' || regexScript.scriptName.trim().length === 0) {\n    throw new Error('Cannot import: regexScript.scriptName is missing or empty');\n}\nawait onRegexImportObjectChange(regexScript, scriptType);","typeGuard":"/** @param {unknown} x */\nconst hasScriptName = (x) => typeof x?.scriptName === 'string' && x.scriptName.trim().length > 0;","tryCatchPattern":"try { await onRegexImportObjectChange(regexScript, scriptType); }\ncatch (e) { if (/No script name/.test(e.message)) { console.warn('skipping unnamed regex import'); } else throw e; }","preventionTips":["Validate import payload schema before calling onRegexImportObjectChange.","Default scriptName to 'Imported Script' when missing rather than crashing.","Disable the import button in UI until a name is provided."],"tags":["regex","validation","import","missing-field"],"backgroundTag":null,"analyzedSha":"8172dcd0ee672d3cd9a5e5f7af134f91a45cd2b8","analyzedAt":"2026-08-13T07:48:40.832Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}