{"record":{"id":"20751df041dd698e","repo":"weaviate/weaviate","slug":"sanitize-file-path-q-w","errorCode":null,"errorMessage":"sanitize file path %q: %w","messagePattern":"sanitize file path %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/repos/db/shard_backup.go","lineNumber":593,"sourceCode":"\t\treturn fmt.Errorf(\"shard version path: %w\", err)\n\t}\n\treturn nil\n}\n\nfunc (s *Shard) GetFileMetadata(ctx context.Context, relativeFilePath string) (file.FileMetadata, error) {\n\ts.haltForTransferMux.Lock()\n\tdefer s.haltForTransferMux.Unlock()\n\n\tif s.haltForTransferCount.Load() == 0 {\n\t\treturn file.FileMetadata{}, fmt.Errorf(\"can not open file %q for reading: illegal state: shard %q is not paused for transfer\",\n\t\t\trelativeFilePath, s.name)\n\t}\n\n\ts.mayResetInactivityDeadline()\n\n\tfinalPath, err := s.sanitizeFilePath(relativeFilePath)\n\tif err != nil {\n\t\treturn file.FileMetadata{}, fmt.Errorf(\"sanitize file path %q: %w\", relativeFilePath, err)\n\t}\n\treturn file.GetFileMetadata(finalPath)\n}\n\nfunc (s *Shard) GetFile(ctx context.Context, relativeFilePath string) (io.ReadCloser, error) {\n\ts.haltForTransferMux.Lock()\n\tdefer s.haltForTransferMux.Unlock()\n\n\tif s.haltForTransferCount.Load() == 0 {\n\t\treturn nil, fmt.Errorf(\"can not open file %q for reading: illegal state: shard %q is not paused for transfer\",\n\t\t\trelativeFilePath, s.name)\n\t}\n\n\ts.mayResetInactivityDeadline()\n\n\tfinalPath, err := s.sanitizeFilePath(relativeFilePath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"sanitize file path %q: %w\", relativeFilePath, err)","sourceCodeStart":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/repos/db/shard_backup.go#L575-L611","documentation":"GetFileMetadata failed while validating the caller-supplied relative path before touching the filesystem. sanitizeFilePath rejects paths that are absolute, cannot have symlinks resolved (typically nonexistent file), or escape the shard root via symlink traversal. This wrapper only adds context; the real condition is the wrapped sanitizeFilePath error.","triggerScenarios":"Thrown at adapters/repos/db/shard_backup.go:593 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped cause: an fs.ErrNotExist means the relative file does not exist in the shard directory; an 'outside shard root' or 'absolute path' cause means the caller passed an invalid/hostile path.","Fix the caller (backup/replication file transfer) to pass only paths relative to the shard root that were obtained from shard directory listings."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}