{"record":{"id":"514a26d01ccac456","repo":"gofr-dev/gofr","slug":"failed-to-list-objects","errorCode":null,"errorMessage":"failed to list objects","messagePattern":"failed to list objects","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gofr/datasource/file/ftp/storage_adapter.go","lineNumber":30,"sourceCode":"\n\t\"github.com/jlaffaye/ftp\"\n\t\"gofr.dev/pkg/gofr/datasource/file\"\n)\n\nvar (\n\t// Storage adapter errors.\n\terrFTPConfigNil            = errors.New(\"FTP config is nil\")\n\terrFTPClientNotInitialized = errors.New(\"FTP client is not initialized\")\n\terrEmptyObjectName         = errors.New(\"object name is empty\")\n\terrInvalidOffset           = errors.New(\"invalid offset: must be >= 0\")\n\terrEmptySourceOrDest       = errors.New(\"source and destination names cannot be empty\")\n\terrSameSourceAndDest       = errors.New(\"source and destination are the same\")\n\terrFailedToCreateReader    = errors.New(\"failed to create reader\")\n\terrFailedToCreateWriter    = errors.New(\"failed to create writer\")\n\terrObjectNotFound          = errors.New(\"object not found\")\n\terrFailedToGetObjectAttrs  = errors.New(\"failed to get object attrs\")\n\terrFailedToDeleteObject    = errors.New(\"failed to delete object\")\n\terrFailedToListObjects     = errors.New(\"failed to list objects\")\n\terrFailedToListDirectory   = errors.New(\"failed to list directory\")\n\terrWriterAlreadyClosed     = errors.New(\"writer already closed\")\n\terrFTPConfigInvalid        = errors.New(\"invalid FTP configuration: host and port are required\")\n)\n\n// Config represents the FTP configuration.\ntype Config struct {\n\tHost        string        // FTP server hostname\n\tUser        string        // FTP username\n\tPassword    string        // FTP password\n\tPort        int           // FTP port\n\tRemoteDir   string        // Remote directory path. Base Path for all FTP Operations.\n\tDialTimeout time.Duration // FTP connection timeout\n}\n\n// storageAdapter adapts FTP client to implement file.StorageProvider.\ntype storageAdapter struct {\n\tcfg  *Config","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/gofr-dev/gofr/blob/187eb24962502e91f1fee856230670958b66e89c/pkg/gofr/datasource/file/ftp/storage_adapter.go#L12-L48","documentation":"errFailedToListObjects is returned by ListObjects when a directory listing (LIST/MLSD) fails on the FTP server. It wraps the underlying goftp error from the listing command. Callers should distinguish it from an empty (but successful) listing.","triggerScenarios":"Calling ListObjects with a prefix whose directory cannot be listed: the path does not exist, permissions deny listing, or the data connection for the transfer fails.","commonSituations":"Listing a directory the FTP user cannot read; passive-mode blocked by firewall so the listing data connection never opens; path is a file, not a directory.","solutions":["Confirm the prefix points to an existing, listable directory (StatObject first)","Check read permission on the directory for the FTP user","Fix passive-mode/firewall configuration so data connections succeed","Retry on transient network failures; inspect the wrapped error for the server reply"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// confirm the prefix is an existing directory before listing\nif _, err := fs.StatObject(ctx, prefix); err != nil { return err }","typeGuard":"func isListError(err error) bool { return errors.Is(err, ftp.ErrFailedToListObjects) }","tryCatchPattern":"objs, err := fs.ListObjects(ctx, prefix)\nif errors.Is(err, ftp.ErrFailedToListObjects) {\n    // check perms/passive mode; retry or fail with context\n    return fmt.Errorf(\"list %s: %w\", prefix, err)\n}","preventionTips":["Ensure passive-mode ports are open between client and server (firewall/NAT)","Verify read permission on every directory you list","Stat the prefix first so you list directories, not files","Add retry with backoff for flaky networks; log the wrapped cause"],"tags":["ftp","listing","network"],"backgroundTag":"ftp-list-failed","analyzedSha":"187eb24962502e91f1fee856230670958b66e89c","analyzedAt":"2026-09-01T20:34:54.554Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}