{"record":{"id":"4143e400d6d3be61","repo":"spring-projects/spring-ai","slug":"unknown-responseformat-type","errorCode":null,"errorMessage":"Unknown ResponseFormat type: ","messagePattern":"Unknown ResponseFormat type: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"models/spring-ai-mistral-ai/src/main/java/org/springframework/ai/mistralai/api/MistralAiApi.java","lineNumber":1041,"sourceCode":"\t\t\t\tJSON_SCHEMA(\"json_schema\");\n\n\t\t\t\tprivate final String value;\n\n\t\t\t\tType(String value) {\n\t\t\t\t\tthis.value = value;\n\t\t\t\t}\n\n\t\t\t\tpublic String getValue() {\n\t\t\t\t\treturn this.value;\n\t\t\t\t}\n\n\t\t\t\tpublic static Type fromValue(String value) {\n\t\t\t\t\tfor (Type type : Type.values()) {\n\t\t\t\t\t\tif (type.value.equals(value)) {\n\t\t\t\t\t\t\treturn type;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthrow new IllegalArgumentException(\"Unknown ResponseFormat type: \" + value);\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * JSON schema object that describes the format of the JSON object. Applicable\n\t\t\t * for the 'json_schema' type only.\n\t\t\t */\n\t\t\t@JsonInclude(Include.NON_NULL)\n\t\t\tpublic static class JsonSchema {\n\n\t\t\t\t@JsonProperty(\"name\")\n\t\t\t\tprivate String name;\n\n\t\t\t\t@JsonProperty(\"schema\")\n\t\t\t\tprivate Map<String, Object> schema;\n\n\t\t\t\t@JsonProperty(\"strict\")","sourceCodeStart":1023,"sourceCodeEnd":1059,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/models/spring-ai-mistral-ai/src/main/java/org/springframework/ai/mistralai/api/MistralAiApi.java#L1023-L1059","documentation":"MistralAiApi.ResponseFormat.Type.fromValue() deserializes the 'response_format' type string returned by (or supplied to) the Mistral API. It throws IllegalArgumentException when the string does not match one of the known enum values (e.g. \"text\", \"json_object\"). This protects callers from silently working with an unrecognized response format.","triggerScenarios":"Deserializing a Mistral chat completion response whose response_format.type string is not one of the enum values, or programmatically calling Type.fromValue() with a typo'd/unsupported value like \"json\" or an empty string.","commonSituations":"Mistral adds a new response_format type in their API while the Spring AI version in use predates it; hand-written JSON fixtures or mocks with misspelled type values; users constructing a ResponseFormat manually with a wrong type string.","solutions":["Upgrade spring-ai-mistral-ai to the latest version so the enum includes newly added Mistral response format types.","Check the exact value string in the payload/response and correct typos (must match a known enum value such as \"text\" or \"json_object\").","If a new Mistral type is genuinely unsupported, construct the request without response_format or use a supported type instead."],"exampleFix":"// before\nResponseFormat.Type.fromValue(\"json\"); // throws\n// after\nResponseFormat.Type.fromValue(\"json_object\"); // valid enum value","handlingStrategy":"try-catch","validationCode":"String type = responseFormat != null ? responseFormat.getType() : null;\nif (type == null || !(type.equals(\"text\") || type.equals(\"json_object\"))) {\n    throw new IllegalArgumentException(\"Unsupported response_format type: \" + type);\n}","typeGuard":"boolean isKnownResponseType(String v) { return v != null && (v.equals(\"text\") || v.equals(\"json_object\")); }","tryCatchPattern":"try {\n    var t = MistralAiApi.ResponseFormat.Type.fromValue(value);\n} catch (IllegalArgumentException e) {\n    // fall back to ResponseFormat for a known-safe value or skip response_format\n}","preventionTips":["Pin and regularly upgrade the spring-ai-mistral-ai version to track Mistral API changes.","Never hand-write response_format strings; use the enum constants.","Validate any recorded/mock payloads against the enum values before replay."],"tags":["api","enum","deserialization","mistral"],"backgroundTag":"invalid-enum-value","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}