{"record":{"id":"49582db4b1a84a4d","repo":"gofr-dev/gofr","slug":"invalid-ftp-provider","errorCode":null,"errorMessage":"invalid FTP provider","messagePattern":"invalid FTP provider","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gofr/datasource/file/ftp/fs.go","lineNumber":14,"sourceCode":"package ftp\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"gofr.dev/pkg/gofr/datasource/file\"\n)\n\nvar (\n\terrInvalidConfig   = errors.New(\"invalid FTP configuration: host and port are required\")\n\terrInvalidProvider = errors.New(\"invalid FTP provider\")\n)\n\nconst defaultTimeout = 10 * time.Second\n\ntype fileSystem struct {\n\t*file.CommonFileSystem\n}\n\n// New creates and validates a new FTP file system.\n// Returns error if connection fails or configuration is invalid.\nfunc New(config *Config) file.FileSystemProvider {\n\tif config == nil {\n\t\tconfig = &Config{}\n\t}\n\n\t// Set default dial timeout if not specified\n\tif config.DialTimeout == 0 {\n\t\tconfig.DialTimeout = 5 * time.Second","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/gofr-dev/gofr/blob/187eb24962502e91f1fee856230670958b66e89c/pkg/gofr/datasource/file/ftp/fs.go#L1-L32","documentation":"errInvalidProvider is a sentinel declared in the ftp package indicating the FTP filesystem's underlying provider (storageAdapter) is invalid or not an expected provider type. It is returned by validateConfig as part of pre-connection sanity checks.","triggerScenarios":"validateConfig determines the wired provider is invalid — e.g. the storage adapter was constructed without the required config/client wiring before Connect() runs.","commonSituations":"Manually constructing or replacing the provider on CommonFileSystem; internal misconfiguration of the adapter after custom setup; version changes in the ftp package internals.","solutions":["Construct the FTP filesystem via ftp.New(config) rather than wiring CommonFileSystem.Provider manually.","Inspect validateConfig's return and reinitialize the filesystem if the provider was replaced.","Update to a matching library version if you rely on internal adapter fields."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Always build the FTP filesystem via the constructor\nfs := ftp.New(cfg) // wires a valid storageAdapter\nif fs == nil { log.Fatal(\"failed to construct FTP filesystem\") }","typeGuard":"func isFTPFileSystem(p file.FileSystemProvider) bool {\n    _, ok := p.(*ftp.FileSystem)\n    return ok\n}","tryCatchPattern":"if err := validate(); errors.Is(err, errInvalidProvider) {\n    fs = ftp.New(cfg) // reinitialize with valid provider\n}","preventionTips":["Never assign CommonFileSystem.Provider manually; use ftp.New.","Do not rely on internal adapter fields across library versions.","Add a smoke test that Connect() succeeds on a valid config."],"tags":["go","ftp","provider","validation"],"backgroundTag":"invalid-provider","analyzedSha":"187eb24962502e91f1fee856230670958b66e89c","analyzedAt":"2026-09-01T20:34:54.554Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}