{"record":{"id":"6166c4c79e85a973","repo":"stanfordnlp/CoreNLP","slug":"unknown-comptype-comptype","errorCode":null,"errorMessage":"Unknown compType: ${compType}","messagePattern":"Unknown compType: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ling/tokensregex/types/ValueFunctions.java","lineNumber":764,"sourceCode":"      this.compType = compType;\n      this.clazz = clazz;\n    }\n\n    @Override\n    public String getParamDesc() {\n      return \"(\" + getTypeName(clazz) + \",\" + getTypeName(clazz) + \")\";\n    }\n\n    public Boolean compare(T o1, T o2) {\n      int res = comparator.compare(o1,o2);\n      switch (compType) {\n        case GT: return res > 0;\n        case LT: return res < 0;\n        case GE: return res >= 0;\n        case LE: return res <= 0;\n        case EQ: return res == 0;\n        case NE: return res != 0;\n        default: throw new UnsupportedOperationException(\"Unknown compType: \" + compType);\n      }\n    }\n\n    @Override\n    public boolean checkArgs(List<Value> in) {\n      if (in.size() != 2) {\n        return false;\n      }\n      if (clazz != null) {\n        if (in.get(0) == null || in.get(0).get() == null || !(clazz.isAssignableFrom(in.get(0).get().getClass()))) {\n          return false;\n        }\n        if (in.get(1) == null || in.get(1).get() == null || !(clazz.isAssignableFrom(in.get(1).get().getClass()))) {\n          return false;\n        }\n      }\n      return true;\n    }","sourceCodeStart":746,"sourceCodeEnd":782,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ling/tokensregex/types/ValueFunctions.java#L746-L782","documentation":"ValueFunctions' comparison helper throws UnsupportedOperationException when the ComparisonFunction's compType is not one of GT, LT, GE, LE, EQ, NE. compType is normally parsed from the expression operator, so this means an unknown/unmapped comparison type reached compareTo.","triggerScenarios":"Invoking a comparison function (e.g. via a CompareExpression) whose compType field was set to null or an enum value outside {GT,LT,GE,LE,EQ,NE}, typically through programmatic construction or a parser bug.","commonSituations":"Custom code constructing Expressions.CompareExpression with a null or custom compType; version drift where a new operator isn't mapped in compareTo; deserialization of expressions with invalid operator strings.","solutions":["Set compType to one of the supported tokens: GT, LT, GE, LE, EQ, NE.","Verify the operator in the expression string parses to a valid compType (e.g. '>', '<', '>=', '<=', '==', '!=').","If adding a custom compType, extend the compareTo switch to handle it instead of relying on the default branch."],"exampleFix":"// before\nExpressions.CompareExpression e = new Expressions.CompareExpression(\"x\", myValue, null);\n// after\nExpressions.CompareExpression e = new Expressions.CompareExpression(\"x\", myValue, Expressions.ComparisonType.GE);","handlingStrategy":"type-guard","validationCode":"if (compType == null || !EnumSet.of(GT, LT, GE, LE, EQ, NE).contains(compType)) {\n    throw new IllegalArgumentException(\"Unsupported compType: \" + compType);\n}","typeGuard":"boolean isValidCompType(Expressions.ComparisonType t) {\n    return t == GT || t == LT || t == GE || t == LE || t == EQ || t == NE;\n}","tryCatchPattern":"try {\n    res = cmpFn.apply(env, args);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Unknown compType\")) {\n        res = Expressions.FALSE; // or surface a config error\n    } else throw e;\n}","preventionTips":["Only construct CompareExpression with the six documented comparison types","Map operator strings through the standard parser instead of hand-building enums","Cover all compType branches in custom comparisons with tests"],"tags":["tokensregex","comparison-operator","unsupported-operation"],"backgroundTag":"invalid-enum-value","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}