{"record":{"id":"17aff117dc6ab21e","repo":"gofr-dev/gofr","slug":"failed-to-get-object-attrs","errorCode":null,"errorMessage":"failed to get object attrs","messagePattern":"failed to get object attrs","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gofr/datasource/file/ftp/storage_adapter.go","lineNumber":28,"sourceCode":"\t\"strings\"\n\t\"time\"\n\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.","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/gofr-dev/gofr/blob/187eb24962502e91f1fee856230670958b66e89c/pkg/gofr/datasource/file/ftp/storage_adapter.go#L10-L46","documentation":"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.","triggerScenarios":"StatObject or DeleteObject when the FTP server rejects/fails the metadata command for the given path, or the control connection is broken mid-command.","commonSituations":"FTP servers without SIZE/MDTM support (rare/legacy servers); transient network interruption; permission restrictions preventing stat on the directory.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// verify the control connection works before metadata calls\nif err := fs.TestConnection(ctx); err != nil { return err }","typeGuard":"func isAttrsError(err error) bool { return errors.Is(err, ftp.ErrFailedToGetObjectAttrs) }","tryCatchPattern":"info, err := fs.StatObject(ctx, name)\nif errors.Is(err, ftp.ErrFailedToGetObjectAttrs) && retryable(err) {\n    // reconnect and retry with backoff\n}","preventionTips":["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"],"tags":["ftp","metadata","object-storage"],"backgroundTag":"ftp-command-failed","analyzedSha":"187eb24962502e91f1fee856230670958b66e89c","analyzedAt":"2026-09-01T20:34:54.554Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}