{"record":{"id":"f848050d0645d720","repo":"HumanSignal/label-studio","slug":"absolute-local-path-self-path-cannot-be-the-sa","errorCode":null,"errorMessage":"Absolute local path \"{self.path}\" cannot be the same as LOCAL_FILES_DOCUMENT_ROOT=\"{settings.LOCAL_FILES_DOCUMENT_ROOT}\" by security reasons. Please add a subdirectory. For example: \"{example_path}\".","messagePattern":"Absolute local path \"(.+?)\" cannot be the same as LOCAL_FILES_DOCUMENT_ROOT=\"(.+?)\" by security reasons\\. Please add a subdirectory\\. For example: \"(.+?)\"\\.","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"error","filePath":"label_studio/io_storages/localfiles/models.py","lineNumber":88,"sourceCode":"    def community_auto_hint():\n        if settings.VERSION_EDITION == 'Community':\n            return (\n                ' Community tip: create a \"mydata\" or \"label-studio-data\" directory next to the Label Studio '\n                'command to auto-enable LOCAL_FILES_DOCUMENT_ROOT when the environment variables are unset.'\n            )\n        return ''\n\n    def validate_connection(self):\n        normalized_path = self._get_storage_path_or_raise(ValidationError)\n        self.path = normalized_path\n        path = Path(normalized_path)\n        document_root = Path(settings.LOCAL_FILES_DOCUMENT_ROOT)\n        example_path = Path(settings.LOCAL_FILES_DOCUMENT_ROOT) / 'dataset1'\n\n        if not path.exists():\n            raise ValidationError(f'Absolute local path \"{self.path}\" does not exist')\n        if document_root == path:\n            raise ValidationError(\n                f'Absolute local path \"{self.path}\" cannot be the same as '\n                f'LOCAL_FILES_DOCUMENT_ROOT=\"{settings.LOCAL_FILES_DOCUMENT_ROOT}\" by security reasons. Please add a subdirectory. '\n                f'For example: \"{example_path}\".'\n            )\n        if document_root not in path.parents:\n            raise ValidationError(\n                f'Absolute local path \"{self.path}\" must be a subdirectory of '\n                f'LOCAL_FILES_DOCUMENT_ROOT=\"{settings.LOCAL_FILES_DOCUMENT_ROOT}\" by security reasons. '\n                f'For example: \"{example_path}\".'\n            )\n        if settings.LOCAL_FILES_SERVING_ENABLED is False:\n            raise ValidationError(\n                'Serving local files from the host filesystem can be a security risk, so '\n                'LOCAL_FILES_SERVING_ENABLED is disabled by default. '\n                'To enable Local Files storage, set the LOCAL_FILES_SERVING_ENABLED environment '\n                'variable to \"true\" and restart Label Studio. See '\n                'https://labelstud.io/guide/storage.html#Local-storage for details.'\n                '\\n\\n'","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/io_storages/localfiles/models.py#L70-L106","documentation":"Label Studio forbids configuring Local Files storage with a path equal to LOCAL_FILES_DOCUMENT_ROOT itself. Exposing the whole document root would let users browse every served file, so validate_connection rejects it with a Django ValidationError. The fix is to point the storage at a subdirectory of the document root.","triggerScenarios":"Creating/updating a Local Files storage where the 'path' field, after normalization, is exactly the value of the LOCAL_FILES_DOCUMENT_ROOT setting (e.g. both are '/label-studio/data').","commonSituations":"Copy-pasting the LOCAL_FILES_DOCUMENT_ROOT value into the storage path field; thinking the document root itself is the dataset folder; Docker setups where only one directory exists so users point at the mount root.","solutions":["Create and use a subdirectory under the document root, e.g. <DOCUMENT_ROOT>/dataset1, and pass that as the storage path","If everything currently sits in the document root, move datasets into dedicated subdirectories","Verify LOCAL_FILES_DOCUMENT_ROOT is set to the intended base (not the dataset dir itself) so the storage path differs"],"exampleFix":"// before\n{ \"path\": \"/label-studio/data\" }   // == LOCAL_FILES_DOCUMENT_ROOT -> rejected\n// after\n{ \"path\": \"/label-studio/data/dataset1\" }","handlingStrategy":"validation","validationCode":"from pathlib import Path\np, root = Path(path), Path('/label-studio/data')\nif p == root:\n    raise SystemExit('Storage path must be a SUBDIRECTORY of LOCAL_FILES_DOCUMENT_ROOT, not the root itself')","typeGuard":null,"tryCatchPattern":"try:\n    storage.validate_connection()\nexcept ValidationError as e:\n    if 'cannot be the same as' in ';'.join(e.messages):\n        logger.error('Point the storage at e.g. %s', Path(root) / 'dataset1')\n    else:\n        raise","preventionTips":["Treat LOCAL_FILES_DOCUMENT_ROOT as a container, never a storage target","Organize datasets one level below the document root","Read the error text — it suggests the exact example path"],"tags":["security","local-storage","validation","configuration"],"backgroundTag":"document-root-path-forbidden","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}