{"record":{"id":"9b73c0824c7a19fc","repo":"JetBrains/intellij-community","slug":"slice-filter-parse-error-enum-constant-not-found","errorCode":"slice.filter.parse.error.enum.constant.not.found","errorMessage":"Enum constant not found: {0}","messagePattern":"Enum constant not found: (.+?)","errorType":"validation","errorClass":"SliceFilterParseException","httpStatus":null,"severity":"error","filePath":"java/java-impl/src/com/intellij/slicer/JavaSliceProvider.java","lineNumber":154,"sourceCode":"        PsiTypes.charType().equals(type) ||\n        PsiTypes.shortType().equals(type) ||\n        PsiTypes.intType().equals(type) ||\n        PsiTypes.longType().equals(type)) {\n      for (RelationType relType : RelationType.values()) {\n        if (filter.startsWith(relType.toString())) {\n          relationType = relType;\n          filter = filter.substring(relType.toString().length()).trim();\n          break;\n        }\n      }\n    }\n    PsiClass psiClass = PsiUtil.resolveClassInClassTypeOnly(type);\n    if (psiClass != null && psiClass.isEnum()) {\n      PsiField enumConstant = psiClass.findFieldByName(filter, false);\n      if (enumConstant instanceof PsiEnumConstant) {\n        return new JavaValueFilter(DfTypes.referenceConstant(enumConstant, type));\n      } else {\n        throw new SliceFilterParseException(JavaBundle.message(\"slice.filter.parse.error.enum.constant.not.found\", filter));\n      }\n    }\n    PsiExpression constant;\n    try {\n      constant = JavaPsiFacade.getElementFactory(expression.getProject()).createExpressionFromText(filter, expression);\n    }\n    catch (IncorrectOperationException ignore) {\n      throw new SliceFilterParseException(JavaBundle.message(\"slice.filter.parse.error.incorrect.expression\", filter));\n    }\n    PsiType constantType = constant.getType();\n    if (constantType == null || !type.isAssignableFrom(constantType)) {\n      throw new SliceFilterParseException(JavaBundle.message(\"slice.filter.parse.error.incorrect.constant.type\", type.getPresentableText()));\n    }\n    Object o = ExpressionUtils.computeConstantExpression(constant);\n    if (o == null) {\n      throw new SliceFilterParseException(JavaBundle.message(\"slice.filter.parse.error.expression.must.evaluate.to.constant\", filter));\n    }\n    if (relationType != RelationType.EQ) {","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/java-impl/src/com/intellij/slicer/JavaSliceProvider.java#L136-L172","documentation":"Thrown by JavaSliceProvider.parseFilter when the value being sliced has an enum class type and the filter text does not name an existing constant of that enum. The parser resolves the enum class with PsiUtil.resolveClassInClassTypeOnly, calls findFieldByName(filter, false), and if the field is not a PsiEnumConstant it throws SliceFilterParseException with the offending filter text.","triggerScenarios":"Slicing a variable of enum type (e.g. Day day) and typing a filter that is not one of its constants (typo, casing mismatch, or a fully qualified name like 'java.time.Day.MONDAY' which findFieldByName does not match).","commonSituations":"Typos or wrong case in constant names ('monday' vs 'MONDAY'); renaming an enum constant so a previously saved/remembered filter no longer resolves; pasting a qualified constant name where only the simple constant name is expected; enum defined with the constant inherited or hidden by a field of the same name.","solutions":["Type the exact simple name of an existing enum constant, matching case (e.g. 'MONDAY', not 'monday').","Check the enum declaration (Ctrl+B on the variable's type) to confirm the constant list and spelling.","Do not prefix the constant with the enum or package name — only the bare constant name is accepted.","If the constant was recently renamed, re-enter the filter with the new name."],"exampleFix":"// before (enum Day { MONDAY, ... }):\nfilter = \"Day.MONDAY\"\n\n// after:\nfilter = \"MONDAY\"","handlingStrategy":"validation","validationCode":"PsiClass c = PsiUtil.resolveClassInClassTypeOnly(type);\nif (c != null && c.isEnum() && !(c.findFieldByName(filter, false) instanceof PsiEnumConstant)) {\n  // filter does not name a constant: offer completion from c.getFields() of type PsiEnumConstant\n}","typeGuard":null,"tryCatchPattern":"try { provider.parseFilter(expression, filter); } catch (SliceFilterParseException e) { /* surface message, keep filter editor open */ }","preventionTips":["Offer enum-constant completion from the sliced variable's enum type instead of free-text entry.","Use the exact constant name; no enum-name prefix, no qualification, case-sensitive."],"tags":["java","intellij","dataflow","slice","enum","user-input"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}