{"record":{"id":"9934aba6e4fa7ec6","repo":"gofr-dev/gofr","slug":"object-not-found-9934ab","errorCode":null,"errorMessage":"object not found","messagePattern":"object not found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gofr/datasource/file/ftp/storage_adapter.go","lineNumber":27,"sourceCode":"\t\"path\"\n\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","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/gofr-dev/gofr/blob/187eb24962502e91f1fee856230670958b66e89c/pkg/gofr/datasource/file/ftp/storage_adapter.go#L9-L45","documentation":"errObjectNotFound is returned when the requested object (file or directory) does not exist on the FTP server. StatObject, readers, DeleteObject and CopyObject all use it as the sentinel for a missing path. Callers can test with errors.Is to implement not-found handling.","triggerScenarios":"Calling StatObject, NewReader, NewRangeReader, DeleteObject, CopyObject, or the internal statFile/statDirectory helpers with a name that has no matching entry on the server.","commonSituations":"Typos or case-sensitivity mismatches in the object name (FTP paths are case-sensitive); file deleted by another process; using an absolute path when the session root differs; stale cache of object names.","solutions":["Check the exact object path, including case and leading slash","List the parent directory (ListDir/ListObjects) to confirm the object exists","Handle it explicitly: if errors.Is(err, ftp.ErrObjectNotFound) { ... create or skip ... }","Verify the FTP user's home/root — relative paths resolve against it, not the server filesystem root"],"exampleFix":"// before\n_, err := fs.StatObject(ctx, \"Reports/Q4.csv\")\n// after\n_, err := fs.StatObject(ctx, \"reports/q4.csv\") // correct case per server listing\nif errors.Is(err, ftp.ErrObjectNotFound) { /* create it */ }","handlingStrategy":"type-guard","validationCode":"// check existence before dependent operations\nif _, err := fs.StatObject(ctx, name); errors.Is(err, ftp.ErrObjectNotFound) {\n    // object absent — create or skip\n}","typeGuard":"func isNotFound(err error) bool { return errors.Is(err, ftp.ErrObjectNotFound) }","tryCatchPattern":"data, err := fs.NewReader(ctx, name)\nif errors.Is(err, ftp.ErrObjectNotFound) {\n    return nil, ErrMissing // map to application-level not-found\n}\nif err != nil { return nil, err }","preventionTips":["Keep object paths in a single well-typed constant/builder to avoid typos","Remember FTP paths are case-sensitive; derive names from ListDir output","Use absolute, canonical paths and verify the FTP user's home directory","Always errors.Is-check the sentinel rather than comparing message strings"],"tags":["ftp","not-found","object-storage"],"backgroundTag":"object-not-found","analyzedSha":"187eb24962502e91f1fee856230670958b66e89c","analyzedAt":"2026-09-01T20:34:54.554Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}