t8y2/dbx · error

invalid %s: %w

Error message

invalid %s: %w

What it means

hoconString (config_file.go:372) wraps any error from the HOCON library's GetStringE as `invalid <path>: <cause>`. This means the key exists at the given HOCON path but cannot be coerced to a string (e.g. it is an object, array, or a value type the resolver rejects). It is returned by the applyHOCON* functions while reading the Java-driver or native Cassandra config file.

Source

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

		}
		value, err = url.PathUnescape(parsed.Path)
		if err != nil {
			return "", err
		}
		if runtime.GOOS == "windows" && len(value) >= 3 && value[0] == '/' && value[2] == ':' {
			value = value[1:]
		}
	}
	return filepath.Clean(filepath.FromSlash(value)), nil
}

func hoconString(config *hocon.Config, path string) (string, bool, error) {
	if config.Get(path) == nil {
		return "", false, nil
	}
	value, err := config.GetStringE(path)
	if err != nil {
		return "", false, fmt.Errorf("invalid %s: %w", path, err)
	}
	return strings.TrimSpace(value), true, nil
}

func firstHOCONString(config *hocon.Config, paths ...string) (string, bool, error) {
	for _, path := range paths {
		value, ok, err := hoconString(config, path)
		if err != nil || ok {
			return value, ok, err
		}
	}
	return "", false, nil
}

func hoconStringMap(config *hocon.Config, path string) (map[string]string, bool, error) {
	if config.Get(path) == nil {
		return nil, false, nil
	}

View on GitHub (pinned to c0390bff16)

Solutions

  1. Read the wrapped cause after 'invalid <path>:' to find the underlying HOCON error and line.
  2. Open the config file at the reported path and ensure the value is a quoted or bare scalar string, not an object or array.
  3. Fix indentation so child keys are not nested beneath the string option.
  4. If a `${substitution}` is involved, define the substitution or escape it (`${?var}` optional syntax) so HOCON can resolve it.

Example fix

// before (application.conf)
datastax-java-driver {
  basic.application.name {
    name = cassandra-client   # object where a string was expected
  }
}
// after
datastax-java-driver {
  basic.application.name = cassandra-client
}
Defensive patterns

Strategy: validation

Validate before calling

func preflightHoconStrings(path string, keys []string) error {
    cfg, err := hocon.ParseFile(path)
    if err != nil {
        return err
    }
    for _, k := range keys {
        if cfg.Get(k) == nil {
            continue
        }
        if _, err := cfg.GetStringE(k); err != nil {
            return fmt.Errorf("%s must be a scalar string in %s: %w", k, path, err)
        }
    }
    return nil
}

Try / catch

if err := applyCassandraConfigFile(cfgPath); err != nil {
    if strings.HasPrefix(err.Error(), "invalid ") {
        var path, cause string
        fmt.Sscanf(err.Error(), "invalid %s", &path)
        log.Fatalf("key %s in %s is not a string: %v — check nesting, arrays, and ${substitutions}", path, cfgPath, err)
    }
    return err
}

Prevention

When it happens

Trigger: A config file key that applyJavaDriverHOCON/applyHOCONSSL/applyHOCONAuthentication/applyNativeHOCON reads via hoconString (e.g. basic.application.name, advanced.auth-provider.class, tls.ca-cert-path) is set to a non-string HOCON value such as a nested object `foo { bar = 1 }`, an array `[a,b]`, or an unparseable substitution.

Common situations: Indentation mistakes turning a scalar into an object (child keys accidentally nested under the option); YAML-style lists pasted into a HOCON string field; unresolved `${...}` substitutions raising errors inside the HOCON resolver.

Related errors


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