gofr-dev/gofr · error
failed to get object attrs
Error message
failed to get object attrs
What it means
errFailedToGetObjectAttrs is returned when the adapter cannot retrieve metadata (size, mod time) for an object from the FTP server, typically because the SIZE or MDTM command failed. StatObject and DeleteObject return it when the existence check itself errors. It is distinct from errObjectNotFound: the object may exist but metadata could not be fetched.
Source
Thrown at pkg/gofr/datasource/file/ftp/storage_adapter.go:28
"strings"
"time"
"github.com/jlaffaye/ftp"
"gofr.dev/pkg/gofr/datasource/file"
)
var (
// Storage adapter errors.
errFTPConfigNil = errors.New("FTP config is nil")
errFTPClientNotInitialized = errors.New("FTP client is not initialized")
errEmptyObjectName = errors.New("object name is empty")
errInvalidOffset = errors.New("invalid offset: must be >= 0")
errEmptySourceOrDest = errors.New("source and destination names cannot be empty")
errSameSourceAndDest = errors.New("source and destination are the same")
errFailedToCreateReader = errors.New("failed to create reader")
errFailedToCreateWriter = errors.New("failed to create writer")
errObjectNotFound = errors.New("object not found")
errFailedToGetObjectAttrs = errors.New("failed to get object attrs")
errFailedToDeleteObject = errors.New("failed to delete object")
errFailedToListObjects = errors.New("failed to list objects")
errFailedToListDirectory = errors.New("failed to list directory")
errWriterAlreadyClosed = errors.New("writer already closed")
errFTPConfigInvalid = errors.New("invalid FTP configuration: host and port are required")
)
// Config represents the FTP configuration.
type Config struct {
Host string // FTP server hostname
User string // FTP username
Password string // FTP password
Port int // FTP port
RemoteDir string // Remote directory path. Base Path for all FTP Operations.
DialTimeout time.Duration // FTP connection timeout
}
// storageAdapter adapts FTP client to implement file.StorageProvider.View on GitHub (pinned to 187eb24962)
Solutions
- Retry the operation — transient network issues often cause command failures
- Verify server support for SIZE/MDTM commands (test with a raw FTP client)
- Check read permissions on the object's parent directory
- Reconnect (Connect) if the control connection was dropped
Defensive patterns
Strategy: retry
Validate before calling
// verify the control connection works before metadata calls
if err := fs.TestConnection(ctx); err != nil { return err } Type guard
func isAttrsError(err error) bool { return errors.Is(err, ftp.ErrFailedToGetObjectAttrs) } Try / catch
info, err := fs.StatObject(ctx, name)
if errors.Is(err, ftp.ErrFailedToGetObjectAttrs) && retryable(err) {
// reconnect and retry with backoff
} Prevention
- Retry transient metadata failures with exponential backoff
- Confirm the FTP server supports SIZE/MDTM before relying on StatObject
- Reconnect after idle periods — control connections often time out
- Distinguish this from ErrObjectNotFound: only retry, don't treat as missing
When it happens
Trigger: StatObject or DeleteObject when the FTP server rejects/fails the metadata command for the given path, or the control connection is broken mid-command.
Common situations: FTP servers without SIZE/MDTM support (rare/legacy servers); transient network interruption; permission restrictions preventing stat on the directory.
Related errors
- failed to create writer
- object not found
- invalid FTP configuration: host and port are required
- invalid FTP provider
- FTP config is nil
AI-assisted analysis of gofr-dev/gofr@187eb24962 (2026-09-01).
Data as JSON: /api/errors/17aff117dc6ab21e.
Report an issue: GitHub.