{"record":{"id":"19d90d486cef9b11","repo":"fatedier/frp","slug":"failed-to-load-existing-data-w","errorCode":null,"errorMessage":"failed to load existing data: %w","messagePattern":"failed to load existing data: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/config/source/store.go","lineNumber":63,"sourceCode":"\nconst (\n\tstoreKindProxy   = \"proxy\"\n\tstoreKindVisitor = \"visitor\"\n)\n\nfunc NewStoreSource(cfg StoreSourceConfig) (*StoreSource, error) {\n\tif cfg.Path == \"\" {\n\t\treturn nil, fmt.Errorf(\"path is required\")\n\t}\n\n\ts := &StoreSource{\n\t\tbaseSource: newBaseSource(),\n\t\tconfig:     cfg,\n\t}\n\n\tif err := s.loadFromFile(); err != nil {\n\t\tif !os.IsNotExist(err) {\n\t\t\treturn nil, fmt.Errorf(\"failed to load existing data: %w\", err)\n\t\t}\n\t}\n\n\treturn s, nil\n}\n\nfunc (s *StoreSource) loadFromFile() error {\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\treturn s.loadFromFileUnlocked()\n}\n\nfunc (s *StoreSource) loadFromFileUnlocked() error {\n\tdata, err := os.ReadFile(s.config.Path)\n\tif err != nil {\n\t\treturn err\n\t}\n","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/fatedier/frp/blob/6c8a8d0a97d03b44e9528d30b30c70cb9d61b405/pkg/config/source/store.go#L45-L81","documentation":"Returned by NewStoreSource when the store file at cfg.Path exists but cannot be read for any reason other than 'file does not exist'. The constructor intentionally treats a missing file as an empty store, so this error means the path exists yet reading it failed (permissions, path is a directory, I/O error). Construction is aborted and no StoreSource is returned.","triggerScenarios":"Calling NewStoreSource(StoreSourceConfig{Path: p}) where p is a directory, a file without read permission for the current user (e.g. mode 0600 owned by root while frpc runs as nobody), or a file on a failed/unmounted volume. The os.IsNotExist check in NewStoreSource only exempts ENOENT; every other error from loadFromFile lands here.","commonSituations":"Running the process once as root (or via sudo) so the store file becomes root-owned, then running it as a service user; pointing Path at a directory like /etc/frp instead of a file; an NFS/FUSE mount that dropped and returns EIO on read; SELinux denying access.","solutions":["Check the path and its permissions: ls -la <path> and confirm it is a regular file readable by the account running the process","Fix ownership/permissions: chown <user> <path> or chmod 644 <path> (or run the process as the owning user)","If Path points to a directory, change it to a file path such as /var/lib/frpc/store.json","If the file is stale and disposable, move or delete it so NewStoreSource starts with an empty store (this discards stored proxies/visitors)","On network filesystems, verify the mount is healthy (mount | grep <dir>, dmesg) before restarting"],"exampleFix":"# before: store file created by root, frpc runs as service user\nPath: /var/lib/frpc/store.json   # -rw------- root root\n\n# after\nsudo chown frpc:frpc /var/lib/frpc/store.json\nsudo chmod 600 /var/lib/frpc/store.json","handlingStrategy":"try-catch","validationCode":"func checkStorePathReadable(path string) error {\n\tfi, err := os.Stat(path)\n\tif errors.Is(err, fs.ErrNotExist) {\n\t\treturn nil // missing file is fine: NewStoreSource treats it as empty store\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\tif fi.IsDir() {\n\t\treturn fmt.Errorf(\"%s is a directory, expected a file\", path)\n\t}\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"store file not readable: %w\", err)\n\t}\n\tf.Close()\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"src, err := source.NewStoreSource(source.StoreSourceConfig{Path: p})\nif err != nil {\n\tif os.IsPermission(err) || errors.Is(err, fs.ErrPermission) {\n\t\t// fix ownership or run as owning user, then exit with actionable message\n\t\tlog.Fatalf(\"no read access to store file %s: chown/chmod it (current uid=%d)\", p, os.Getuid())\n\t}\n\tlog.Fatalf(\"open store: %v\", err)\n}","preventionTips":["Pre-create the store file location at deploy time with correct ownership instead of relying on first-run creation by whichever user gets there first","Never run the process alternately as root and non-root against the same store path","Keep the store on a local filesystem, not NFS/FUSE, to avoid EIO on read"],"tags":["filesystem","permissions","initialization","go","config-store"],"backgroundTag":null,"analyzedSha":"6c8a8d0a97d03b44e9528d30b30c70cb9d61b405","analyzedAt":"2026-08-15T06:53:27.215Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}