{"record":{"id":"ca7493261a5607a6","repo":"alibaba/spring-ai-alibaba","slug":"invalid-status","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/AccountStatus.java","lineNumber":66,"sourceCode":"\tprivate final Integer status;\n\n\t/** String representation of the status */\n\tprivate final String value;\n\n\t/**\n\t * Get AccountStatus by numeric status code\n\t * @param status numeric status code\n\t * @return corresponding AccountStatus\n\t * @throws IllegalArgumentException if status is invalid\n\t */\n\tpublic static AccountStatus of(Integer status) {\n\t\tfor (AccountStatus accountStatus : AccountStatus.values()) {\n\t\t\tif (accountStatus.status.equals(status)) {\n\t\t\t\treturn accountStatus;\n\t\t\t}\n\t\t}\n\n\t\tthrow new IllegalArgumentException(\"Invalid status: \" + status);\n\t}\n\n}\n","sourceCodeStart":48,"sourceCodeEnd":70,"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/AccountStatus.java#L48-L70","documentation":"AccountStatus.of() throws IllegalArgumentException when the supplied status string matches no AccountStatus constant. The enum defines the allowed account lifecycle states and refuses unknown values rather than silently coercing them.","triggerScenarios":"Calling AccountStatus.of(status) with a string not present in the enum's values (null, empty, or a status stored by another component/version).","commonSituations":"Reading account rows from a database written by a different schema version; admin UI sending hand-typed status values; case mismatches like \"ACTIVE\" vs \"active\".","solutions":["Pass exactly one of the status strings defined by AccountStatus constants.","Check case sensitivity and whitespace; normalize with trim()/toUpperCase() if the enum expects uppercase.","Catch IllegalArgumentException at the boundary and map to a validation error for the client.","If a new state is required, add a new AccountStatus constant rather than inventing a raw string."],"exampleFix":"// before\nAccountStatus st = AccountStatus.of(\"enabled\"); // throws\n// after\nAccountStatus st = AccountStatus.of(\"active\"); // use a defined value","handlingStrategy":"validation","validationCode":"boolean valid = Arrays.stream(AccountStatus.values())\n    .anyMatch(s -> s.getStatus().equals(candidate));","typeGuard":"Optional<AccountStatus> tryStatus(String s) {\n  try { return Optional.of(AccountStatus.of(s)); }\n  catch (IllegalArgumentException e) { return Optional.empty(); }\n}","tryCatchPattern":"try {\n  st = AccountStatus.of(raw);\n} catch (IllegalArgumentException e) {\n  throw new BadRequestException(\"Unknown account status: \" + raw);\n}","preventionTips":["Restrict admin UI/API inputs to a dropdown fed by AccountStatus.values().","Normalize case and whitespace of status strings from DB/clients.","Add a migration check if statuses were renamed between versions.","Never hand-type status strings; copy from the enum's defined values."],"tags":["enum","illegal-argument","account"],"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"}