{"record":{"id":"c3695a691ec09846","repo":"vxcontrol/pentagi","slug":"reading-resources-cache-w","errorCode":null,"errorMessage":"reading resources cache: %w","messagePattern":"reading resources cache: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/flowfiles/files.go","lineNumber":69,"sourceCode":"type TarEntry struct {\n\tLocalPath string\n\tTarPath   string\n}\n\nfunc List(dataDir string, flowID uint64) (Files, error) {\n\tuploadsEntries, err := ListDirEntries(FlowUploadsDir(dataDir, flowID), UploadsDirName)\n\tif err != nil {\n\t\treturn Files{}, fmt.Errorf(\"reading uploads cache: %w\", err)\n\t}\n\n\tcontainerEntries, err := ListDirEntriesRecursive(FlowContainerDir(dataDir, flowID), ContainerDirName)\n\tif err != nil {\n\t\treturn Files{}, fmt.Errorf(\"reading container cache: %w\", err)\n\t}\n\n\tresourcesEntries, err := ListDirEntriesRecursive(FlowResourcesDir(dataDir, flowID), ResourcesDirName)\n\tif err != nil {\n\t\treturn Files{}, fmt.Errorf(\"reading resources cache: %w\", err)\n\t}\n\n\tfiles := append(uploadsEntries, containerEntries...)\n\tfiles = append(files, resourcesEntries...)\n\tSort(files)\n\treturn Files{\n\t\tFiles: files,\n\t\tTotal: uint64(len(files)),\n\t}, nil\n}\n\nfunc FlowDataDir(dataDir string, flowID uint64) string {\n\treturn filepath.Join(dataDir, fmt.Sprintf(\"flow-%d-data\", flowID))\n}\n\nfunc FlowUploadsDir(dataDir string, flowID uint64) string {\n\treturn filepath.Join(FlowDataDir(dataDir, flowID), UploadsDirName)\n}","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/flowfiles/files.go#L51-L87","documentation":"List() fails while recursively listing the per-flow resources directory (FlowResourcesDir). Third of the three cache-read steps; if it fails the whole file listing is aborted and the wrapped error returned.","triggerScenarios":"List(dataDir, flowID) with a missing/unreadable resources directory or an OS readdir error during recursion.","commonSituations":"Resources never added to the flow so the dir was never created; resources uploaded by another process with different ownership; disk/volume issues on the data mount.","solutions":["Create the resources directory when the flow is initialized or on first resource add","Treat a missing directory as an empty resources list","Check ownership/permissions of FlowResourcesDir(dataDir, flowID)","Verify the underlying volume health and free space"],"exampleFix":"// before\nreturn Files{}, fmt.Errorf(\"reading resources cache: %w\", err)\n// after\nif os.IsNotExist(err) {\n    resourcesEntries = nil\n} else {\n    return Files{}, fmt.Errorf(\"reading resources cache: %w\", err)\n}","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(files.FlowResourcesDir(dataDir, flowID)); os.IsNotExist(err) {\n    os.MkdirAll(files.FlowResourcesDir(dataDir, flowID), 0o755)\n}","typeGuard":"func isMissingResourcesCache(err error) bool {\n    return strings.Contains(err.Error(), \"reading resources cache\") && errors.Is(err, os.ErrNotExist)\n}","tryCatchPattern":"files, err := flowfiles.List(dataDir, flowID)\nif err != nil && strings.Contains(err.Error(), \"reading resources cache\") {\n    if os.IsNotExist(err) { files = flowfiles.Files{} } else { return err }\n}","preventionTips":["Create the resources dir on flow init or first resource add","Keep resource-writer and flow-reader user identities aligned","Alert on filesystem errors from the data volume","Use the same permission model across all three cache roots"],"tags":["filesystem","flowfiles","directory"],"backgroundTag":"directory-read-failed","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}