gofr-dev/gofr · error

invalid FTP provider

Error message

invalid FTP provider

What it means

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.

Source

Thrown at pkg/gofr/datasource/file/ftp/fs.go:14

package ftp

import (
	"context"
	"errors"
	"fmt"
	"time"

	"gofr.dev/pkg/gofr/datasource/file"
)

var (
	errInvalidConfig   = errors.New("invalid FTP configuration: host and port are required")
	errInvalidProvider = errors.New("invalid FTP provider")
)

const defaultTimeout = 10 * time.Second

type fileSystem struct {
	*file.CommonFileSystem
}

// New creates and validates a new FTP file system.
// Returns error if connection fails or configuration is invalid.
func New(config *Config) file.FileSystemProvider {
	if config == nil {
		config = &Config{}
	}

	// Set default dial timeout if not specified
	if config.DialTimeout == 0 {
		config.DialTimeout = 5 * time.Second

View on GitHub (pinned to 187eb24962)

Solutions

  1. Construct the FTP filesystem via ftp.New(config) rather than wiring CommonFileSystem.Provider manually.
  2. Inspect validateConfig's return and reinitialize the filesystem if the provider was replaced.
  3. Update to a matching library version if you rely on internal adapter fields.
Defensive patterns

Strategy: validation

Validate before calling

// Always build the FTP filesystem via the constructor
fs := ftp.New(cfg) // wires a valid storageAdapter
if fs == nil { log.Fatal("failed to construct FTP filesystem") }

Type guard

func isFTPFileSystem(p file.FileSystemProvider) bool {
    _, ok := p.(*ftp.FileSystem)
    return ok
}

Try / catch

if err := validate(); errors.Is(err, errInvalidProvider) {
    fs = ftp.New(cfg) // reinitialize with valid provider
}

Prevention

When it happens

Trigger: validateConfig determines the wired provider is invalid — e.g. the storage adapter was constructed without the required config/client wiring before Connect() runs.

Common situations: Manually constructing or replacing the provider on CommonFileSystem; internal misconfiguration of the adapter after custom setup; version changes in the ftp package internals.

Related errors


AI-assisted analysis of gofr-dev/gofr@187eb24962 (2026-09-01). Data as JSON: /api/errors/49582db4b1a84a4d. Report an issue: GitHub.