{"record":{"id":"ad19131d2b7008b2","repo":"stanfordnlp/CoreNLP","slug":"could-not-find-language-or-predefined-relative-pro","errorCode":null,"errorMessage":"Could not find Language or predefined relative pronouns pattern in the request","messagePattern":"Could not find Language or predefined relative pronouns pattern in the request","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/trees/ud/ProcessUniversalEnhancerRequest.java","lineNumber":87,"sourceCode":"   */\n  public static Pattern getRelativePronouns(CoreNLPProtos.DependencyEnhancerRequest request) {\n    if (request.hasRelativePronouns()) {\n      return Pattern.compile(request.getRelativePronouns());\n    }\n    if (request.hasLanguage()) {\n      switch(request.getLanguage()) {\n      case English:\n      case UniversalEnglish:\n        return EnglishPatterns.RELATIVIZING_WORD_PATTERN;\n      case Chinese:\n      case UniversalChinese:\n        // there are no relative pronouns in Chinese!\n        return null;\n      default:\n        throw new IllegalArgumentException(\"Relative word pattern not defined for \" + request.getLanguage());\n      }\n    }\n    throw new IllegalArgumentException(\"Could not find Language or predefined relative pronouns pattern in the request\");\n  }\n\n  /**\n   * Process a single request, adding enhanced dependencies to each sentence in the document\n   */\n  @Override\n  public void processInputStream(InputStream in, OutputStream out) throws IOException {\n    CoreNLPProtos.DependencyEnhancerRequest request = CoreNLPProtos.DependencyEnhancerRequest.parseFrom(in);\n\n    Pattern relativePronounsPattern = getRelativePronouns(request);\n\n    CoreNLPProtos.Document response = processRequest(relativePronounsPattern, request);\n    response.writeTo(out);\n  }\n\n  /**\n   * The inherited main program will either enhance a single document,\n   * or will listen to stdin and enhance every document that comes in","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/trees/ud/ProcessUniversalEnhancerRequest.java#L69-L105","documentation":"The second guard in ProcessUniversalEnhancerRequest.getRelativePronouns: if the request has no Language set (and no predefined relative-pronouns pattern supplied), the method throws IllegalArgumentException(\"Could not find Language or predefined relative pronouns pattern in the request\"). It fires after the language-switch when the request lacks both pieces of information.","triggerScenarios":"Sending a ProcessUniversalEnhancerRequest with no language field populated and no predefined relative-pronouns pattern, then invoking relativePronounsPattern/getRelativePronouns during enhancement.","commonSituations":"Building the request programmatically and forgetting setLanguage; deserializing a request where the language field was dropped; calling the enhancer pipeline directly without a fully populated request object.","solutions":["Call setLanguage(...) on the request before processing","Supply a predefined relative-pronouns pattern in the request when language detection is unavailable","Validate the request (language or pattern present) before invoking the enhancer","Catch IllegalArgumentException and return a clear request-validation error to the caller"],"exampleFix":"// before\nProcessUniversalEnhancerRequest request = new ProcessUniversalEnhancerRequest();\nenhancer.process(request); // no language\n// after\nProcessUniversalEnhancerRequest request = new ProcessUniversalEnhancerRequest();\nrequest.setLanguage(Language.English);\nenhancer.process(request);","handlingStrategy":"validation","validationCode":"if (request.getLanguage() == null && request.getRelativePronounsPattern() == null) {\n  throw new IllegalArgumentException(\"Request must set language or a relative pronouns pattern\");\n}","typeGuard":null,"tryCatchPattern":"try { enhancer.process(request); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"Could not find Language\")) { throw new RequestValidationException(\"language/pattern missing\", e); } throw e; }","preventionTips":["Always call setLanguage before processing enhancement requests","Validate request objects centrally before the pipeline","Check deserialized requests for dropped language fields"],"tags":["ud-enhancer","missing-argument","request-validation","illegal-argument"],"backgroundTag":"missing-required-argument","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"}