{"record":{"id":"93f733d1f3e36add","repo":"stanfordnlp/CoreNLP","slug":"unknown-side-side","errorCode":null,"errorMessage":"Unknown side <side>","messagePattern":"Unknown side <side>","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/shiftreduce/BinaryTransition.java","lineNumber":199,"sourceCode":"   * Add a binary node to the existing node on top of the stack\n   */\n  public State apply(State state, double scoreDelta) {\n    TreeShapedStack<Tree> stack = state.stack;\n    Tree right = stack.peek();\n    stack = stack.pop();\n    Tree left = stack.peek();\n    stack = stack.pop();\n\n    Tree head;\n    switch(side) {\n    case LEFT:\n      head = left;\n      break;\n    case RIGHT:\n      head = right;\n      break;\n    default:\n      throw new IllegalArgumentException(\"Unknown side \" + side);\n    }\n\n    if (!(head.label() instanceof CoreLabel)) {\n      throw new IllegalArgumentException(\"Stack should have CoreLabel nodes\");\n    }\n    CoreLabel headLabel = (CoreLabel) head.label();\n\n    CoreLabel production = new CoreLabel();\n    production.setValue(label);\n    production.set(TreeCoreAnnotations.HeadWordLabelAnnotation.class, headLabel.get(TreeCoreAnnotations.HeadWordLabelAnnotation.class));\n    production.set(TreeCoreAnnotations.HeadTagLabelAnnotation.class, headLabel.get(TreeCoreAnnotations.HeadTagLabelAnnotation.class));\n    Tree newTop = new LabeledScoredTreeNode(production);\n    newTop.addChild(left);\n    newTop.addChild(right);\n\n    stack = stack.push(newTop);\n\n    return new State(stack, state.transitions.push(this), state.separators, state.sentence, state.tokenPosition, state.score + scoreDelta, false);","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/shiftreduce/BinaryTransition.java#L181-L217","documentation":"BinaryTransition.apply() switches on the transition's Side enum (LEFT/RIGHT) when choosing which stack node is the head; an unrecognized side value falls to the default and throws IllegalArgumentException. With only two enum constants this normally indicates a corrupted or externally constructed transition.","triggerScenarios":"Applying a BinaryTransition whose side field is null or a deserialized/modified value outside {LEFT, RIGHT}, e.g. from hand-built transition sequences or bad serialization.","commonSituations":"Custom training code constructing BinaryTransition with a side not set, Java deserialization of an altered enum, or third-party code injecting invalid states into the shift-reduce parser.","solutions":["Ensure BinaryTransition is always created via its constructor with Side.LEFT or Side.RIGHT.","Check that transition sequences were serialized/deserialized with matching CoreNLP versions.","Add an assertion/log of transition.side before calling apply() in custom training loops.","Rebuild the transition sequence from the tree rather than reusing stale transition objects."],"exampleFix":"// before\nnew BinaryTransition(label, null, isRoot);\n// after\nnew BinaryTransition(label, BinaryTransition.Side.LEFT, isRoot);","handlingStrategy":"type-guard","validationCode":"if (t instanceof BinaryTransition && t.side != BinaryTransition.Side.LEFT && t.side != BinaryTransition.Side.RIGHT)\n    throw new IllegalStateException(\"Invalid BinaryTransition side\");","typeGuard":"boolean hasValidSide(BinaryTransition t) {\n    return t.side == BinaryTransition.Side.LEFT || t.side == BinaryTransition.Side.RIGHT;\n}","tryCatchPattern":"try {\n    transition.apply(state);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Unknown side\")) {\n        // discard/rebuild the transition sequence\n    }\n}","preventionTips":["Create transitions only through the public constructor with explicit Side values.","Version-align serialized models/transition sequences.","Assert transition invariants before applying in custom loops."],"tags":["java","enum","internal","nlp"],"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-15T23:17:13.987Z"}