{"record":{"id":"c0947f96d169b55a","repo":"t8y2/dbx","slug":"invalid-cassandra-configfile-w-c0947f","errorCode":null,"errorMessage":"invalid Cassandra configfile: %w","messagePattern":"invalid Cassandra configfile: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/cassandra-go/config_file.go","lineNumber":23,"sourceCode":"\t\"fmt\"\n\t\"net/url\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n\n\tgocql \"github.com/apache/cassandra-gocql-driver/v2\"\n\t\"github.com/gurkankaymak/hocon\"\n)\n\nconst javaDriverConfigPrefix = \"datastax-java-driver.\"\n\nfunc applyCassandraConfigFile(config *cassandraConfig, rawPath string) error {\n\tpath, err := normalizeLocalFilePath(rawPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid Cassandra configfile: %w\", err)\n\t}\n\tif path == \"\" {\n\t\treturn nil\n\t}\n\tinfo, err := os.Stat(path)\n\tif err != nil {\n\t\tif errors.Is(err, os.ErrNotExist) {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"read Cassandra configfile %s: %w\", path, err)\n\t}\n\tif !info.Mode().IsRegular() {\n\t\treturn fmt.Errorf(\"Cassandra configfile is not a regular file: %s\", path)\n\t}\n\tparsed, err := hocon.ParseResource(path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"parse Cassandra configfile %s: %w\", path, err)\n\t}","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/cassandra-go/config_file.go#L5-L41","documentation":"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.).","triggerScenarios":"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.","commonSituations":"Env var containing a bad path; YAML/HOCON value with quotes or whitespace anomalies; using a remote URI where only local files are accepted.","solutions":["Inspect the wrapped error (%w) for the underlying path failure and fix the path value","Use an absolute local filesystem path for the configfile option","Ensure no surrounding quotes/whitespace or unsupported URI scheme in the value","Test with os.Stat on the same path in your environment"],"exampleFix":"// before\nconfigfile: \"http://configs/cassandra.conf\"\n// after\nconfigfile: \"/etc/odigos/cassandra.conf\"","handlingStrategy":"validation","validationCode":"path := cfg.ConfigFile\nif path != \"\" && !filepath.IsAbs(path) {\n    abs, err := filepath.Abs(path)\n    if err != nil { return fmt.Errorf(\"configfile not usable: %w\", err) }\n    cfg.ConfigFile = abs\n}","typeGuard":"func isPlausibleLocalPath(p string) bool {\n    return p == \"\" || (filepath.IsAbs(p) && !strings.Contains(p, \"://\"))\n}","tryCatchPattern":"if err := parseCassandraConfig(raw); err != nil {\n    var pathErr *fs.PathError\n    if strings.Contains(err.Error(), \"invalid Cassandra configfile\") || errors.As(err, &pathErr) {\n        return fmt.Errorf(\"check the configfile option, got %q: %w\", raw.ConfigFile, err)\n    }\n    return err\n}","preventionTips":["Use absolute local paths for configfile; never URIs","Trim quotes/whitespace from env-injected values","Check the file path resolves inside your container image, not just on the host"],"tags":["cassandra","config","file-io"],"backgroundTag":"invalid-file-path","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}