{"record":{"id":"cf2ac0c74adfb3bc","repo":"languagetool-org/languagetool","slug":"disambiguated-pos-cannot-be-null-with-posselect","errorCode":null,"errorMessage":"disambiguated POS cannot be null with posSelect == null and \" + disambAction","messagePattern":"disambiguated POS cannot be null with posSelect == null and \" \\+ disambAction","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/tagging/disambiguation/rules/DisambiguationPatternRule.java","lineNumber":76,"sourceCode":"   * @param description Description to be shown (name)\n   * @param disambAction the action to be executed on found token(s)\n   * @since public since 2.5\n   */\n  public DisambiguationPatternRule(String id, String description,\n                                   Language language, List<PatternToken> patternTokens,\n                                   String disambiguatedPOS, Match posSelect,\n                                   DisambiguatorAction disambAction) {\n    super(id, description, language, patternTokens, true);\n    if (disambiguatedPOS == null && posSelect == null\n        && disambAction != DisambiguatorAction.UNIFY\n        && disambAction != DisambiguatorAction.ADD\n        && disambAction != DisambiguatorAction.REMOVE\n        && disambAction != DisambiguatorAction.IMMUNIZE\n        && disambAction != DisambiguatorAction.REPLACE\n        && disambAction != DisambiguatorAction.FILTERALL\n        && disambAction != DisambiguatorAction.IGNORE_SPELLING\n        && disambAction != DisambiguatorAction.ADDCHUNK) {\n      throw new NullPointerException(\"disambiguated POS cannot be null with posSelect == null and \" + disambAction);\n    }\n    this.disambiguatedPOS = disambiguatedPOS;\n    this.matchElement = posSelect;\n    this.disAction = Objects.requireNonNull(disambAction);\n    setMessage(\"\");\n    suggestionsOutMsg = \"\";\n  }\n\n  /**\n   * Used to add new interpretations.\n   * @param newReadings\n   *          An array of AnalyzedTokens. The length of the array should be the\n   *          same as the number of the tokens matched and selected by\n   *          {@code <marker>...</marker>} elements.\n   */\n  public final void setNewInterpretations(AnalyzedToken[] newReadings) {\n    newTokenReadings = newReadings.clone();\n  }","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/tagging/disambiguation/rules/DisambiguationPatternRule.java#L58-L94","documentation":"Constructor invariant check for DisambiguationPatternRule: an action that needs a replacement POS (e.g. REPLACE) was requested, but both disambiguatedPOS and posSelect are null, so there is no POS to apply. This is an API misuse guard — rule XML is normally validated earlier, so it fires mostly when building rules programmatically.","triggerScenarios":"Thrown at languagetool-core/src/main/java/org/languagetool/tagging/disambiguation/rules/DisambiguationPatternRule.java:76 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide a non-null disambiguatedPOS or a posSelect Match when using a POS-modifying action","Use the correct DisambiguatorAction (e.g. UNIFY or IGNORE) when no POS replacement is intended","Fix the rule XML so the action element carries its postag or match attribute"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}