{"record":{"id":"71dc08d40f3a8d6e","repo":"stanfordnlp/CoreNLP","slug":"check-flag-in-markmentionrelation-dcoref-mentione","errorCode":null,"errorMessage":"check flag in markMentionRelation (dcoref/MentionExtractor.java)","messagePattern":"check flag in markMentionRelation \\(dcoref/MentionExtractor\\.java\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/coref/data/DocumentPreprocessor.java","lineNumber":929,"sourceCode":"      for(Mention m2 : orderedMentions){\n        if(m1==m2) continue;\n        // Ignore if m2 and m1 are in list relationship\n        if (m1.isListMemberOf(m2) || m2.isListMemberOf(m1) || m1.isMemberOfSameList(m2)) {\n          //Redwood.log(\"debug-preprocessor\", \"Not checking '\" + m1 + \"' and '\" + m2 + \"' for \" + flag + \": in list relationship\");\n          continue;\n        }\n        for(Pair<Integer, Integer> foundPair: foundPairs){\n          if (foundPair.first() == m1.headIndex && foundPair.second() == m2.headIndex) {\n            if(flag.equals(\"APPOSITION\")) {\n              if ( ! foundPair.first().equals(foundPair.second()) || m2.insideIn(m1)) {\n                m2.addApposition(m1);\n              }\n            }\n            else if(flag.equals(\"PREDICATE_NOMINATIVE\")) {\n              m2.addPredicateNominatives(m1);\n            }\n            else if(flag.equals(\"RELATIVE_PRONOUN\")) m2.addRelativePronoun(m1);\n            else throw new RuntimeException(\"check flag in markMentionRelation (dcoref/MentionExtractor.java)\");\n          }\n        }\n      }\n    }\n  }\n\n//  private static final TregexPattern relativePronounPattern = TregexPattern.compile(\"NP < (NP=m1 $.. (SBAR < (WHNP < WP|WDT=m2)))\");\n//  private static void findRelativePronouns(Tree tree, Set<Pair<Integer, Integer>> relativePronounPairs) {\n//    findTreePattern(tree, relativePronounPattern, relativePronounPairs);\n//  }\n}\n","sourceCodeStart":911,"sourceCodeEnd":941,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/coref/data/DocumentPreprocessor.java#L911-L941","documentation":"markMentionRelation (now in DocumentPreprocessor) throws when an unrecognized relation flag string reaches it. The flag set (APPOS, PREDICATE_NOMINATIVE, RELATIVE_PRONOUN, etc.) is internal; receiving an unknown value is an internal invariant violation indicating version drift between code that emits flags and code that consumes them.","triggerScenarios":"DocumentPreprocessor construction invoking markMentionRelation where flag equals none of the enumerated values — caused by mixing classes from different CoreNLP versions or a modified enumeration of relation flags.","commonSituations":"Classpath containing two CoreNLP jar versions (e.g. a shaded/older dcoref MentionExtractor with new flags or vice versa); custom forks patched on one side only; OSGi/shading issues pulling stale classes.","solutions":["Ensure a single consistent CoreNLP version on the classpath (mvn dependency:tree; remove old jars)","Clean rebuild to eliminate stale compiled classes mixing old and new relation flags","Do not patch markMentionRelation flag generation without updating the corresponding case list","Upgrade the whole CoreNLP dependency rather than individual coref classes"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Detect duplicate CoreNLP versions on the classpath\nEnumeration<URL> res = ClassLoader.getSystemResources(\"edu/stanford/nlp/coref/data/DocumentPreprocessor.class\");\nif (res.hasMoreElements() && res.nextElement() != null && res.hasMoreElements())\n  throw new IllegalStateException(\"Multiple CoreNLP classes found on classpath\");","typeGuard":null,"tryCatchPattern":"try {\n  new DocumentPreprocessor();\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"check flag in markMentionRelation\")) {\n    logger.severe(\"Version drift: unknown relation flag; check classpath for mixed CoreNLP jars\");\n  } else throw e;\n}","preventionTips":["Enforce a single CoreNLP version via dependency management (dependency:tree, shade relocation)","Never mix classes from different CoreNLP jars on the classpath","If patching the flag enum, update producer and consumer together","Clean build artifacts after upgrades"],"tags":["coref","internal-invariant","classpath","version-mismatch"],"backgroundTag":"internal-invariant-violation","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"}