t8y2/dbx · error

invalid Cassandra configfile: %w

Error message

invalid Cassandra configfile: %w

What it means

applyCassandraConfigFile wraps any failure from normalizeLocalFilePath with this error. It means the configfile option value could not be resolved to a valid local file path (malformed path, unsupported scheme, etc.).

Source

Thrown at agents/drivers/cassandra-go/config_file.go:23

	"fmt"
	"net/url"
	"os"
	"path/filepath"
	"runtime"
	"strconv"
	"strings"
	"time"

	gocql "github.com/apache/cassandra-gocql-driver/v2"
	"github.com/gurkankaymak/hocon"
)

const javaDriverConfigPrefix = "datastax-java-driver."

func applyCassandraConfigFile(config *cassandraConfig, rawPath string) error {
	path, err := normalizeLocalFilePath(rawPath)
	if err != nil {
		return fmt.Errorf("invalid Cassandra configfile: %w", err)
	}
	if path == "" {
		return nil
	}
	info, err := os.Stat(path)
	if err != nil {
		if errors.Is(err, os.ErrNotExist) {
			return nil
		}
		return fmt.Errorf("read Cassandra configfile %s: %w", path, err)
	}
	if !info.Mode().IsRegular() {
		return fmt.Errorf("Cassandra configfile is not a regular file: %s", path)
	}
	parsed, err := hocon.ParseResource(path)
	if err != nil {
		return fmt.Errorf("parse Cassandra configfile %s: %w", path, err)
	}

View on GitHub (pinned to c0390bff16)

Solutions

  1. Inspect the wrapped error (%w) for the underlying path failure and fix the path value
  2. Use an absolute local filesystem path for the configfile option
  3. Ensure no surrounding quotes/whitespace or unsupported URI scheme in the value
  4. Test with os.Stat on the same path in your environment

Example fix

// before
configfile: "http://configs/cassandra.conf"
// after
configfile: "/etc/odigos/cassandra.conf"
Defensive patterns

Strategy: validation

Validate before calling

path := cfg.ConfigFile
if path != "" && !filepath.IsAbs(path) {
    abs, err := filepath.Abs(path)
    if err != nil { return fmt.Errorf("configfile not usable: %w", err) }
    cfg.ConfigFile = abs
}

Type guard

func isPlausibleLocalPath(p string) bool {
    return p == "" || (filepath.IsAbs(p) && !strings.Contains(p, "://"))
}

Try / catch

if err := parseCassandraConfig(raw); err != nil {
    var pathErr *fs.PathError
    if strings.Contains(err.Error(), "invalid Cassandra configfile") || errors.As(err, &pathErr) {
        return fmt.Errorf("check the configfile option, got %q: %w", raw.ConfigFile, err)
    }
    return err
}

Prevention

When it happens

Trigger: Passing an invalid rawPath to the configfile option — e.g. an empty-but-set value that fails normalization, a URL-style path, or a path with illegal characters.

Common situations: Env var containing a bad path; YAML/HOCON value with quotes or whitespace anomalies; using a remote URI where only local files are accepted.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/c0947f96d169b55a. Report an issue: GitHub.