{"record":{"id":"0ed1f763fb04a068","repo":"apache/cassandra","slug":"unsupported-format-formatstring-supported","errorCode":null,"errorMessage":"Unsupported format \" + formatString + \" supported formats are YAML, MINIFIED-YAML, JSON, MINIFIED-JSON","messagePattern":"Unsupported format \" \\+ formatString \\+ \" supported formats are YAML, MINIFIED-YAML, JSON, MINIFIED-JSON","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/utils/PojoToString.java","lineNumber":85,"sourceCode":"        public boolean isYaml()\n        {\n            return this == YAML || this == MINIFIED_YAML;\n        }\n\n        public static Format fromString(String formatString)\n        {\n            formatString = toUpperCaseLocalized(formatString);\n            switch (formatString)\n            {\n                case \"YAML\":\n                    return YAML;\n                case \"MINIFIED-YAML\":\n                    return MINIFIED_YAML;\n                case \"JSON\":\n                    return JSON;\n                case \"MINIFIED-JSON\":\n                    return MINIFIED_JSON;\n                default: throw new IllegalArgumentException(\"Unsupported format \" + formatString\n                                                            + \" supported formats are YAML, MINIFIED-YAML, JSON, MINIFIED-JSON\");\n            }\n        }\n    }\n    private static final Set<Class<?>> ALLOWED_PRIMITIVES = ImmutableSet.of(\n        String.class,\n        Double.class,\n        Float.class,\n        Long.class,\n        Integer.class,\n        Short.class,\n        Byte.class\n    );\n\n    private static final List<Class<?>> ALLOWED_COLLECTIONS = ImmutableList.of(\n        List.class,\n        Set.class\n    );","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/utils/PojoToString.java#L67-L103","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nPojoToString.Format f = PojoToString.Format.fromString(config.format); // \"json\" -> IllegalArgumentException\n// after\nString normalized = config.format == null ? \"YAML\" : config.format.trim().toUpperCase(Locale.ROOT);\nPojoToString.Format f = PojoToString.Format.fromString(normalized);","handlingStrategy":"validation","validationCode":"Set<String> allowed = Set.of(\"YAML\",\"MINIFIED-YAML\",\"JSON\",\"MINIFIED-JSON\");\nif (formatString == null || !allowed.contains(formatString.trim().toUpperCase(Locale.ROOT))) throw new IllegalArgumentException(\"format must be one of \" + allowed);","typeGuard":null,"tryCatchPattern":"try { fmt = PojoToString.Format.fromString(raw); } catch (IllegalArgumentException e) { fmt = PojoToString.Format.YAML; logger.warn(\"bad format '{}' defaulting to YAML\", raw); }","preventionTips":["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"],"tags":["configuration","format","argument-validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}