{"record":{"id":"9fe74fb3b77b4519","repo":"octobercms/october","slug":"editor-lang-filesystem-directory-name-cant-be-emp","errorCode":null,"errorMessage":"editor::lang.filesystem.directory_name_cant_be_empty","messagePattern":"editor::lang\\.filesystem\\.directory_name_cant_be_empty","errorType":"validation","errorClass":"ApplicationException","httpStatus":null,"severity":"warning","filePath":"modules/editor/traits/FileSystemFunctions.php","lineNumber":27,"sourceCode":"use ApplicationException;\nuse Symfony\\Component\\HttpFoundation\\File\\UploadedFile;\n\n/**\n * FileSystemFunctions implements common file and directory management functions for Tailor extensions.\n */\ntrait FileSystemFunctions\n{\n    /**\n     * editorCreateDirectory\n     */\n    protected function editorCreateDirectory($basePath, $newName, $parent)\n    {\n        if (!strlen($basePath)) {\n            throw new SystemException('The directory base path must not be empty');\n        }\n\n        if (!strlen($newName)) {\n            throw new ApplicationException(Lang::get('editor::lang.filesystem.directory_name_cant_be_empty'));\n        }\n\n        if (!$this->validateFileSystemPath($newName)) {\n            throw new ApplicationException(Lang::get('editor::lang.filesystem.invalid_path'));\n        }\n\n        if (strlen($parent) && !$this->validateFileSystemPath($parent)) {\n            throw new ApplicationException(Lang::get('editor::lang.filesystem.invalid_path'));\n        }\n\n        if (!$this->validateFileSystemName($newName)) {\n            throw new ApplicationException(Lang::get('editor::lang.filesystem.invalid_name'));\n        }\n\n        $newFullPath = $basePath.'/'.$parent.'/'.$newName;\n        if (file_exists($newFullPath) && is_dir($newFullPath)) {\n            throw new ApplicationException(Lang::get('editor::lang.filesystem.already_exists'));\n        }","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/editor/traits/FileSystemFunctions.php#L9-L45","documentation":"FileSystemFunctions::editorCreateDirectory validates the 'new directory' request made from the backend code editor. If the submitted new name is empty after checks, this ApplicationException (editor::lang.filesystem.directory_name_cant_be_empty) is returned. It is a user-input guard that fires before any path validation or filesystem access happens.","triggerScenarios":"POSTing a create-directory request to the editor controller with an empty newName; a custom editor integration that submits the form before the name field is filled; whitespace-only name that PHP casts to empty.","commonSituations":"Front-end bug letting the 'new folder' dialog submit with no input; automated scripts calling the editor API without the name parameter; browser autofill or JS errors clearing the field.","solutions":["Provide a non-empty directory name in the request.","Add required-field client validation on the new-folder dialog before submitting.","Trim the input in the caller so whitespace-only names are caught client-side.","Verify the request parameter name matches what the editor API expects (newName)."],"exampleFix":"// before\n$request->input('newName') === '';\n\n// after\nif (!strlen(trim($name))) {\n    // show client-side message instead of posting\n}","handlingStrategy":"validation","validationCode":"$name = trim((string) $newName);\nif ($name === '') {\n    throw new \\ValidationException(['name' => 'Directory name cannot be empty']);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make the new-folder input required in the editor UI.","Trim input before submitting.","Reject empty names client-side so the user never sees the server error."],"tags":["editor","filesystem","validation","input"],"backgroundTag":"empty-filename","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}