{"record":{"id":"0b7e5987f36ad759","repo":"stanfordnlp/CoreNLP","slug":"coordination-node-must-have-at-least-2-children","errorCode":null,"errorMessage":"Coordination node must have at least 2 children.","messagePattern":"Coordination node must have at least 2 children\\.","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/CoordinationPattern.java","lineNumber":33,"sourceCode":"  private static Redwood.RedwoodChannels log = Redwood.channels(CoordinationPattern.class);\n\n  private static final long serialVersionUID = -3122330899634961002L;\n  private final boolean isConj;\n  private final boolean isNodeCoord;\n  /**\n   * Represents whether this is the root coordination.  If so, the\n   * children have a higher operation priority, as the : operator is\n   * the lowest precedence possible.\n   */\n  private final boolean isRoot;\n  private final List<SemgrexPattern> children;\n\n  /* if isConj is true, then it is an \"AND\" ; if it is false, it is an \"OR\".*/\n  /* if isNodeCoord is true, then it is a node coordination conj; if it is false, then\n           * \tit is a relation coordination conj. */\n  public CoordinationPattern(boolean isNodeCoord, List<SemgrexPattern> children, boolean isConj, boolean isRoot) {\n    if (children.size() < 2) {\n      throw new RuntimeException(\"Coordination node must have at least 2 children.\");\n    }\n    this.children = Collections.unmodifiableList(children);\n    this.isConj = isConj;\n    this.isNodeCoord = isNodeCoord;\n    this.isRoot = isRoot;\n  }\n\n  public boolean isNodeCoord() { return isNodeCoord; }\n\n  @Override\n  public void setChild(SemgrexPattern child) {\n    if (isNodeCoord) {\n      for (Object c : children) {\n        if (c instanceof NodePattern)\n          ((NodePattern)c).setChild(child);\n      }\n    } else {\n","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/CoordinationPattern.java#L15-L51","documentation":"The CoordinationPattern constructor throws RuntimeException when fewer than 2 child patterns are supplied. A coordination node in a Semgrex pattern represents AND/OR of sub-patterns, which is meaningless with 0 or 1 children.","triggerScenarios":"Constructing new CoordinationPattern(isNodeCoord, listOfOnePattern, isConj, isRoot) with a list of size 0 or 1 — usually when a parser or builder collects children programmatically and only one alternative was found.","commonSituations":"Programmatic Semgrex pattern construction from configuration or grammar files where a coordination clause has a single branch; parser bug that drops duplicate children.","solutions":["Ensure at least 2 child SemgrexPatterns exist before constructing a CoordinationPattern","If only one child, use the child pattern directly instead of wrapping it in a coordination","Fix the pattern parser/builder so single-branch coordinations are simplified away"],"exampleFix":"// before\nnew CoordinationPattern(isNodeCoord, Collections.singletonList(child), isConj, isRoot);\n// after\nSemgrexPattern pattern = children.size() == 1 ? children.get(0)\n    : new CoordinationPattern(isNodeCoord, children, isConj, isRoot);","handlingStrategy":"validation","validationCode":"if (children == null || children.size() < 2) throw new IllegalArgumentException(\"CoordinationPattern needs >= 2 children\");","typeGuard":null,"tryCatchPattern":"try { SemgrexPattern p = new CoordinationPattern(isNodeCoord, children, isConj, isRoot); } catch (RuntimeException e) { fallback = children.size() == 1 ? children.get(0) : null; }","preventionTips":["Check children size before wrapping in a coordination node","Simplify single-child coordinations to the child pattern itself","Add unit tests for pattern builders that assemble coordinations from dynamic input"],"tags":["java","semgrex","pattern-construction"],"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-17T15:17:12.973Z"}