{"record":{"id":"31595d18e486ffc4","repo":"stanfordnlp/CoreNLP","slug":"invalid-value-for-key","errorCode":null,"errorMessage":"Invalid value  for key: ","messagePattern":"Invalid value  for key: ","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ling/tokensregex/ComplexNodePattern.java","lineNumber":104,"sourceCode":"              break;\n            case \"::EXISTS\":\n            case \"::NOT_NIL\":\n              p.add(c, new NotNilAnnotationPattern());\n              break;\n            case \"::IS_NUM\":\n              p.add(c, new NumericAnnotationPattern(0, NumericAnnotationPattern.CmpType.IS_NUM));\n              break;\n            default:\n              boolean ok = false;\n              if (env != null) {\n                Object custom = env.get(value);\n                if (custom != null) {\n                  p.add(c, (NodePattern) custom);\n                  ok = true;\n                }\n              }\n              if (!ok) {\n                throw new IllegalArgumentException(\"Invalid value \" + value + \" for key: \" + attr);\n              }\n              break;\n          }\n        } else if (value.startsWith(\"<=\")) {\n          Double v = Double.parseDouble(value.substring(2));\n          p.add(c, new NumericAnnotationPattern(v, NumericAnnotationPattern.CmpType.LE));\n        } else if (value.startsWith(\">=\")) {\n          Double v = Double.parseDouble(value.substring(2));\n          p.add(c, new NumericAnnotationPattern(v, NumericAnnotationPattern.CmpType.GE));\n        } else if (value.startsWith(\"==\")) {\n          Double v = Double.parseDouble(value.substring(2));\n          p.add(c, new NumericAnnotationPattern(v, NumericAnnotationPattern.CmpType.EQ));\n        } else if (value.startsWith(\"!=\")) {\n          Double v = Double.parseDouble(value.substring(2));\n          p.add(c, new NumericAnnotationPattern(v, NumericAnnotationPattern.CmpType.NE));\n        } else if (value.startsWith(\">\")) {\n          Double v = Double.parseDouble(value.substring(1));\n          p.add(c, new NumericAnnotationPattern(v, NumericAnnotationPattern.CmpType.GT));","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ling/tokensregex/ComplexNodePattern.java#L86-L122","documentation":"Thrown by ComplexNodePattern.populate when parsing an attribute value string in a TokensRegex rule. Each value string is matched against prefixes like '>=', '>', '<=', '<' or a plain token pattern; if none match and no custom parser handled it, the value's syntax is unsupported for that annotation key. The message includes the offending value and attribute name.","triggerScenarios":"Calling ComplexNodePattern.valueOf(attr, value, env) (or parsing a TokensRegex node expression) with a value string that is not a recognized prefix expression (e.g. '>5'), not a plain [A-Za-z0-9_+-.]+ token, and has no registered custom parser for the key.","commonSituations":"Typos in rule files (e.g. '= 5' with a space, '~5', empty string after '='), using regex-only syntax in a numeric context, or referencing a key without a custom parser for the value's format.","solutions":["Check the exact value string in the rule; it must start with >=, >, <=, < or match [A-Za-z0-9_+-.]+","Register a custom parser for the key via env, or use a supported expression form","Quote the value as a regex string pattern (e.g. /.../) if it was meant to match text"],"exampleFix":"// before (TokensRegex rule)\n{ word:=\"5\" }\n// after\n{ word:5 }","handlingStrategy":"validation","validationCode":"private static final java.util.regex.Pattern OK = java.util.regex.Pattern.compile(\"[A-Za-z0-9_+-.]+\");\nboolean validValue(String v) { return v != null && (v.matches(\"(>=|<=|<|>).*\") || OK.matcher(v).matches()); }\nif (!validValue(value)) throw new IllegalArgumentException(\"Unsupported TokensRegex value: \" + value);","typeGuard":"boolean isSupportedValueSyntax(String v) { return v != null && !v.isBlank() && (v.startsWith(\">=\") || v.startsWith(\"<=\") || v.startsWith(\">\") || v.startsWith(\"<\") || v.matches(\"[A-Za-z0-9_+-.]+\")); }","tryCatchPattern":"try { p = ComplexNodePattern.valueOf(attr, value, env); } catch (IllegalArgumentException e) { log.error(\"Bad TokensRegex attribute value: {} -> {}\", attr, value, e); throw new RuleSyntaxException(value); }","preventionTips":["Quote free-text values as /regex/ in rules","Keep values free of spaces unless wrapped as regex","Test rule files with a small extractor before deploying"],"tags":["tokensregex","parsing","invalid-value"],"backgroundTag":"invalid-argument-value","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}