{"record":{"id":"a073882356cb1413","repo":"stanfordnlp/CoreNLP","slug":"cannot-infer-requirements-for-annotator-annotat","errorCode":null,"errorMessage":"Cannot infer requirements for annotator: ${annotator}","messagePattern":"Cannot infer requirements for annotator: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/pipeline/StanfordCoreNLP.java","lineNumber":498,"sourceCode":"   */\n  public static String ensurePrerequisiteAnnotators(String[] annotators, Properties props) {\n    int posIndex = ArrayUtils.indexOf(annotators, Annotator.STANFORD_POS);\n    int parseIndex = ArrayUtils.indexOf(annotators, Annotator.STANFORD_PARSE);\n    boolean useParseForPos = ((parseIndex >= 0) && (posIndex < 0)); // Already doing the parsing, use the parsing for the pos tag\n\n    // Get an unordered set of annotators\n    Set<String> unorderedAnnotators = new LinkedHashSet<>();  // linked to preserve order\n    Collections.addAll(unorderedAnnotators, annotators);\n    for (String annotator : annotators) {\n      // Add the annotator\n      if (!getNamedAnnotators().containsKey(annotator.toLowerCase())) {\n        throw new IllegalArgumentException(\"Unknown annotator: \" + annotator);\n      }\n\n      // Add its transitive dependencies\n      unorderedAnnotators.add(annotator.toLowerCase());\n      if (!Annotator.DEFAULT_REQUIREMENTS.containsKey(annotator.toLowerCase())) {\n        throw new IllegalArgumentException(\"Cannot infer requirements for annotator: \" + annotator);\n      }\n      Queue<String> fringe = new LinkedList<>(Annotator.DEFAULT_REQUIREMENTS.get(annotator.toLowerCase()));\n      int ticks = 0;\n      while (!fringe.isEmpty()) {\n        ticks += 1;\n        if (ticks == 1000000) {\n          throw new IllegalStateException(\"[INTERNAL ERROR] Annotators have a circular dependency.\");\n        }\n        String prereq = fringe.poll();\n        unorderedAnnotators.add(prereq);\n        fringe.addAll(Annotator.DEFAULT_REQUIREMENTS.get(prereq.toLowerCase()));\n      }\n    }\n\n    if (useParseForPos) {\n      unorderedAnnotators.remove(Annotator.STANFORD_POS);\n    }\n","sourceCodeStart":480,"sourceCodeEnd":516,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/StanfordCoreNLP.java#L480-L516","documentation":"After confirming an annotator exists, ensurePrerequisiteAnnotators looks it up in Annotator.DEFAULT_REQUIREMENTS to compute its prerequisite chain. If the annotator has no entry there, its requirements cannot be inferred and an IllegalArgumentException is thrown.","triggerScenarios":"Requesting a registered annotator (often a custom one registered via customAnnotatorClass, or one lacking a DEFAULT_REQUIREMENTS entry) in ensurePrerequisiteAnnotators, e.g. via ensurePrerequisiteAnnotators call on a pipeline requiring dependency ordering.","commonSituations":"Custom annotators plugged in through customAnnotatorClass that were never added to DEFAULT_REQUIREMENTS; CoreNLP version skew where an annotator exists but requirements metadata was added later.","solutions":["Replace the custom annotator with a built-in one that has requirement metadata.","Implement the Annotator.Requirements interface / provide a Requirements implementation so requirements can be inferred.","Upgrade/downgrade CoreNLP so the annotator has a DEFAULT_REQUIREMENTS entry.","Order the annotators manually in the 'annotators' property and avoid the path that infers requirements, if API allows."],"exampleFix":"// before\nprops.setProperty(\"annotators\", \"tokenize,ssplit,mycustom\"); // mycustom has no requirements\n// after\nprops.setProperty(\"customAnnotatorClass.mycustom\", \"com.example.MyAnnotator\");\nprops.setProperty(\"annotators\", \"tokenize,ssplit\"); // handle custom annotator separately","handlingStrategy":"validation","validationCode":"for (String a : annotators) {\n  if (!Annotator.DEFAULT_REQUIREMENTS.containsKey(a.toLowerCase()) &&\n      !isBuiltinAnnotator(a)) {\n    throw new IllegalArgumentException(\"Annotator lacks requirement metadata: \" + a);\n  }\n}","typeGuard":null,"tryCatchPattern":"try { StanfordCoreNLP.ensurePrerequisiteAnnotators(props, annotators, true); } catch (IllegalArgumentException e) { /* fall back to manually ordered annotator list */ }","preventionTips":["Give custom Annotator implementations a Requirements implementation.","Keep custom annotators out of the auto-prerequisite path unless metadata exists.","Pin a CoreNLP version where all requested annotators have DEFAULT_REQUIREMENTS entries."],"tags":["java","annotators","requirements","configuration"],"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"}