{"record":{"id":"3892e92ff58cd904","repo":"microsoft/aspire","slug":"unknown-value-value","errorCode":null,"errorMessage":"Unknown value: \" + value","messagePattern":"Unknown value: \" \\+ value","errorType":"exception","errorClass":"IllegalArgumentException (in generated Java code)","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.CodeGeneration.Java/AtsJavaCodeGenerator.cs","lineNumber":695,"sourceCode":"                var member = members[i];\n                var memberName = ToUpperSnakeCase(member);\n                var suffix = i < members.Length - 1 ? \",\" : \";\";\n                WriteLine($\"    {memberName}(\\\"{member}\\\"){suffix}\");\n            }\n            WriteLine();\n            WriteLine(\"    private final String value;\");\n            WriteLine();\n            WriteLine($\"    {enumName}(String value) {{\");\n            WriteLine(\"        this.value = value;\");\n            WriteLine(\"    }\");\n            WriteLine();\n            WriteLine(\"    public String getValue() { return value; }\");\n            WriteLine();\n            WriteLine($\"    public static {enumName} fromValue(String value) {{\");\n            WriteLine($\"        for ({enumName} e : values()) {{\");\n            WriteLine(\"            if (e.value.equals(value)) return e;\");\n            WriteLine(\"        }\");\n            WriteLine(\"        throw new IllegalArgumentException(\\\"Unknown value: \\\" + value);\");\n            WriteLine(\"    }\");\n            WriteLine(\"}\");\n            WriteLine();\n        }\n    }\n\n    private void GenerateDtoTypes(IReadOnlyList<AtsDtoTypeInfo> dtoTypes)\n    {\n        if (dtoTypes.Count == 0)\n        {\n            return;\n        }\n\n        WriteLine(\"// ============================================================================\");\n        WriteLine(\"// DTOs\");\n        WriteLine(\"// ============================================================================\");\n        WriteLine();\n","sourceCodeStart":677,"sourceCodeEnd":713,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.CodeGeneration.Java/AtsJavaCodeGenerator.cs#L677-L713","documentation":"This is not a .NET runtime exception — it is a generated Java source line emitted by AtsJavaCodeGenerator.GenerateEnumTypes (called from GenerateAspireSdk). Every generated Java enum's fromValue method throws IllegalArgumentException(\"Unknown value: \" + value) at Java runtime when the incoming string does not equal any enum constant's value.","triggerScenarios":"Calling the generated static method <EnumName>.fromValue(String) in the produced Java SDK with a string that is not one of the declared enum values — e.g., a newer server enum value consumed by older generated code.","commonSituations":"Server introduces a new enum literal after Java code was generated; hand-written callers pass misspelled or wrong-cased values; deserializing API responses containing values the generator never saw.","solutions":["Regenerate the Java code from the current ATs schema so the enum includes the new value.","Match the exact enum value string (values are case-sensitive in the generated equals check).","Wrap fromValue calls in try/catch (IllegalArgumentException) with a fallback UNKNOWN handling path.","Upgrade the generated SDK package to the version matching the server's enum set."],"exampleFix":"// before\nMode mode = Mode.fromValue(payload.get(\"mode\"));\n// after\nMode mode;\ntry {\n    mode = Mode.fromValue(payload.get(\"mode\"));\n} catch (IllegalArgumentException e) {\n    mode = Mode.UNKNOWN; // handle value from newer schema\n}","handlingStrategy":"try-catch","validationCode":"// Java: validate before conversion\nSet<String> valid = Arrays.stream(Mode.values()).map(Mode::getValue).collect(Collectors.toSet());\nif (!valid.contains(rawValue)) {\n    // route to fallback instead of fromValue\n}","typeGuard":"// Java\nstatic boolean isKnownMode(String v) {\n    return Arrays.stream(Mode.values()).anyMatch(m -> m.getValue().equals(v));\n}","tryCatchPattern":"try {\n    mode = Mode.fromValue(rawValue);\n} catch (IllegalArgumentException e) {\n    logger.warn(\"Unknown enum value: {}\", rawValue);\n    mode = Mode.UNKNOWN;\n}","preventionTips":["Regenerate Java code whenever the ATs schema adds enum values.","Never build enum value strings by hand; use the enum constants.","Design generated enums with an UNKNOWN constant for forward compatibility."],"tags":["java","code-generation","enum","deserialization"],"backgroundTag":"invalid-enum-value","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}