{"record":{"id":"a7d7e42a64a95f73","repo":"alibaba/spring-ai-alibaba","slug":"invalid-status-a7d7e4","errorCode":null,"errorMessage":"Invalid status: ","messagePattern":"Invalid status: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-runtime/src/main/java/com/alibaba/cloud/ai/studio/runtime/enums/AppStatus.java","lineNumber":61,"sourceCode":"\t@EnumValue\n\tprivate final Integer status; // Numeric status code\n\n\tprivate final String value; // String representation of the status\n\n\t/**\n\t * Converts a numeric status code to its corresponding AppStatus enum value.\n\t * @param status Numeric status code\n\t * @return Corresponding AppStatus enum value\n\t * @throws IllegalArgumentException if the status code is invalid\n\t */\n\tpublic static AppStatus of(Integer status) {\n\t\tfor (AppStatus appStatus : AppStatus.values()) {\n\t\t\tif (appStatus.status.equals(status)) {\n\t\t\t\treturn appStatus;\n\t\t\t}\n\t\t}\n\n\t\tthrow new IllegalArgumentException(\"Invalid status: \" + status);\n\t}\n\n}\n","sourceCodeStart":43,"sourceCodeEnd":65,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-runtime/src/main/java/com/alibaba/cloud/ai/studio/runtime/enums/AppStatus.java#L43-L65","documentation":"AppStatus.of throws IllegalArgumentException when no enum constant matches the numeric status code in AppStatus.values() — the DB/value source contains a status integer outside the defined set, typically from schema drift or corrupt data.","triggerScenarios":"Calling AppStatus.of(status) with null, empty, or a value outside the enum's defined statuses.","commonSituations":"Legacy app records persisted with statuses later renamed; clients sending enums by name instead of the expected value string; copy-paste of status strings between different enum types (e.g. CommonStatus values).","solutions":["Use a status string that matches one of AppStatus's constant values exactly.","Trim/case-normalize the incoming string before conversion.","Handle IllegalArgumentException from of() when input is user- or DB-sourced.","Migrate stored data if statuses were renamed across versions."],"exampleFix":"// before\nAppStatus st = AppStatus.of(\"running\"); // throws if not defined\n// after\nAppStatus st = AppStatus.of(\"published\"); // verify against enum values","handlingStrategy":"validation","validationCode":"boolean valid = Arrays.stream(AppStatus.values())\n    .anyMatch(s -> s.getStatus().equals(candidate));","typeGuard":"Optional<AppStatus> tryAppStatus(String s) {\n  try { return Optional.of(AppStatus.of(s)); }\n  catch (IllegalArgumentException e) { return Optional.empty(); }\n}","tryCatchPattern":"try {\n  st = AppStatus.of(raw);\n} catch (IllegalArgumentException e) {\n  st = AppStatus.DRAFT; // or reject with a validation error\n}","preventionTips":["Feed status pickers from AppStatus.values() rather than hardcoded strings.","Don't reuse status strings from other enums (CommonStatus/AccountStatus).","Normalize/trim external input before calling of().","Catch IllegalArgumentException when data comes from persisted records."],"tags":["enum","illegal-argument","app"],"backgroundTag":"invalid-enum-value","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}