apache/cassandra · error · IllegalArgumentException
Unsupported format " + formatString + " supported formats…
Error message
Unsupported format " + formatString + " supported formats are YAML, MINIFIED-YAML, JSON, MINIFIED-JSON
What it means
PojoToString.Format.fromString parses a user-supplied format string into the Format enum (YAML, MINIFIED-YAML, JSON, MINIFIED-JSON). Unknown strings throw this IllegalArgumentException. It is strict input validation on serialization/deserialization format selection.
Solutions
- Use exactly one of: YAML, MINIFIED-YAML, JSON, MINIFIED-JSON (uppercase, with hyphen)
- Normalize/trim the input before parsing (e.g. value.trim().toUpperCase(Locale.ROOT))
- Check the source of the format string (config file, flag, env var) for typos or stale values
- Add a fallback default format at the call site if the value is optional
Example fix
// before PojoToString.Format f = PojoToString.Format.fromString(config.format); // "json" -> IllegalArgumentException // after String normalized = config.format == null ? "YAML" : config.format.trim().toUpperCase(Locale.ROOT); PojoToString.Format f = PojoToString.Format.fromString(normalized);
Defensive patterns
Strategy: validation
Validate before calling
Set<String> allowed = Set.of("YAML","MINIFIED-YAML","JSON","MINIFIED-JSON");
if (formatString == null || !allowed.contains(formatString.trim().toUpperCase(Locale.ROOT))) throw new IllegalArgumentException("format must be one of " + allowed); Try / catch
try { fmt = PojoToString.Format.fromString(raw); } catch (IllegalArgumentException e) { fmt = PojoToString.Format.YAML; logger.warn("bad format '{}' defaulting to YAML", raw); } Prevention
- Uppercase+trim user-supplied format strings before parsing
- Expose a dropdown/whitelist of supported formats in tooling
- Add a default fallback for optional format settings
- Test config parsing with unknown values
When it happens
Trigger: Calling PojoToString.Format.fromString with any string other than the four supported values, e.g. "yaml" (wrong case), "JSON_PRETTY", or an empty string from an unset config option.
Common situations: Typing format values in cassandra config or CLI flags with wrong casing, copy-pasting formats from other tools (e.g. "json-pretty"), or older/newer Cassandra versions where the format list differs.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Commit log position must be given as
- Invalid modifier specification
- Latency must be specified in terms of milliseconds (with…
- A CQL blob string must start with "0x"
- a hints file cannot be configured for both compression and…
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/0ed1f763fb04a068.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/utils/PojoToString.java:85
public boolean isYaml()
{
return this == YAML || this == MINIFIED_YAML;
}
public static Format fromString(String formatString)
{
formatString = toUpperCaseLocalized(formatString);
switch (formatString)
{
case "YAML":
return YAML;
case "MINIFIED-YAML":
return MINIFIED_YAML;
case "JSON":
return JSON;
case "MINIFIED-JSON":
return MINIFIED_JSON;
default: throw new IllegalArgumentException("Unsupported format " + formatString
+ " supported formats are YAML, MINIFIED-YAML, JSON, MINIFIED-JSON");
}
}
}
private static final Set<Class<?>> ALLOWED_PRIMITIVES = ImmutableSet.of(
String.class,
Double.class,
Float.class,
Long.class,
Integer.class,
Short.class,
Byte.class
);
private static final List<Class<?>> ALLOWED_COLLECTIONS = ImmutableList.of(
List.class,
Set.class
);View on GitHub (pinned to 88fd0f6a0e)