{"record":{"id":"a7cc04cccc32e777","repo":"XTLS/Xray-core","slug":"asset-is-not-a-regular-file","errorCode":null,"errorMessage":"asset is not a regular file","messagePattern":"asset is not a regular file","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/platform/filesystem/file.go","lineNumber":69,"sourceCode":"\tpath, _, err := getAssetFileLocation(file)\n\treturn path, err\n}\n\nfunc getAssetFileLocation(file string) (string, os.FileInfo, error) {\n\tif !filepath.IsLocal(file) || file == \".\" {\n\t\treturn \"\", nil, errors.New(\"asset path must stay in asset directory\")\n\t}\n\tlocal, err := filepath.Localize(file)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\tpath := platform.GetAssetLocation(local)\n\tinfo, err := os.Stat(path)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\tif !info.Mode().IsRegular() {\n\t\treturn \"\", nil, errors.New(\"asset is not a regular file\")\n\t}\n\treturn path, info, nil\n}\n\nfunc ReadCert(file string) ([]byte, error) {\n\tif filepath.IsAbs(file) {\n\t\treturn ReadFile(file)\n\t}\n\treturn ReadFile(platform.GetCertLocation(file))\n}\n\nfunc CopyFile(dst string, src string) error {\n\tbytes, err := ReadFile(src)\n\tif err != nil {\n\t\treturn err\n\t}\n\tf, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY, 0o644)\n\tif err != nil {","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/common/platform/filesystem/file.go#L51-L87","documentation":"Returned after os.Stat succeeds but the target inside the asset directory is not a regular file: it is a directory, symlink to something irregular, device, socket, etc. The asset resolver only serves plain files.","triggerScenarios":"Calling ResolveAsset/StatAsset with a name that resolves to a subdirectory (e.g. 'subdir') or a special file inside the asset location.","commonSituations":"Users creating a directory named like the expected asset (e.g. a 'geosite' folder), or symlinks inside the asset dir pointing at fifos/devices; misconfigured downloads that create directories.","solutions":["Check with ls/file that the asset entry is a regular file and replace any directory with the real file","Remove symlinks pointing at non-regular targets inside the asset directory","Re-download the asset (e.g. geodata files) so a plain file exists at the expected name"],"exampleFix":"# replace a mistakenly-created directory with the real asset file\nrm -rf /usr/local/share/xray/geosite.dat\ncp geosite.dat /usr/local/share/xray/geosite.dat","handlingStrategy":"validation","validationCode":"if info, err := os.Stat(assetPath); err == nil && !info.Mode().IsRegular() {\n    return errors.New(\"asset is a directory/special file; replace with the real file\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use os.Stat pre-checks when asset dir contents are user-managed","Re-download assets from trusted sources"],"tags":["filesystem","asset","validation"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}