{"record":{"id":"c40bc3ec21878068","repo":"alibaba/spring-ai-alibaba","slug":"unknown-experiment-status-code-code","errorCode":null,"errorMessage":"Unknown experiment status code: ${code}","messagePattern":"Unknown experiment status code: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/enums/ExperimentStatus.java","lineNumber":52,"sourceCode":"        this.code = code;\n        this.description = description;\n    }\n\n    public String getCode() {\n        return code;\n    }\n\n    public String getDescription() {\n        return description;\n    }\n\n    public static ExperimentStatus fromCode(String code) {\n        for (ExperimentStatus status : values()) {\n            if (status.getCode().equals(code)) {\n                return status;\n            }\n        }\n        throw new IllegalArgumentException(\"Unknown experiment status code: \" + code);\n    }\n} \n","sourceCodeStart":34,"sourceCodeEnd":55,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/enums/ExperimentStatus.java#L34-L55","documentation":"ExperimentStatus.fromCode(String) looks up the enum constant whose code matches the given string and throws IllegalArgumentException \"Unknown experiment status code: X\" when no constant matches. This guards the mapping from persisted/transported status codes back to enum values.","triggerScenarios":"Calling ExperimentStatus.fromCode() with a code not present in the enum's values(), e.g. a typo, an old/renamed code from a persisted DB row, or a status written by a different version of the app.","commonSituations":"Reading legacy experiment rows whose status codes predate an enum refactor; hand-edited data; API clients sending unrecognized status strings; case mismatch (\"RUNNING\" vs \"running\").","solutions":["Print/log the offending code and compare with the codes defined in ExperimentStatus (getCode() of each constant).","Fix the data source (DB record, API payload) to use a valid code.","If a new status was added elsewhere, add the matching constant to ExperimentStatus.","Normalize case/trimming before lookup if codes may vary in case.","If legacy codes must be supported, map them to new constants in fromCode."],"exampleFix":"// before\nthrow new IllegalArgumentException(\"Unknown experiment status code: \" + code);\n// after\nExperimentStatus s = Arrays.stream(values()).filter(st -> st.getCode().equalsIgnoreCase(code)).findFirst().orElse(null);\nif (s != null) return s;\nreturn ExperimentStatus.PENDING; // or throw with a list of valid codes in the message","handlingStrategy":"try-catch","validationCode":"boolean valid = Arrays.stream(ExperimentStatus.values())\n    .anyMatch(s -> s.getCode().equals(code));","typeGuard":null,"tryCatchPattern":"try { status = ExperimentStatus.fromCode(code); } catch (IllegalArgumentException e) { log.warn(\"Unknown status '{}', defaulting to PENDING\", code); status = ExperimentStatus.PENDING; }","preventionTips":["Never persist free-form status strings — always write codes produced by the enum itself","Treat enum refactorings as data migrations: map old codes to new ones","Case-normalize codes read from external systems before lookup","Include the list of valid codes in error messages for faster debugging"],"tags":["enum","invalid-value","status-code","java"],"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"}