{"record":{"id":"e0c0eb98f5e0ed82","repo":"stanfordnlp/CoreNLP","slug":"dependencies-type-not-implemented-commandargs","errorCode":null,"errorMessage":"Dependencies type not implemented: <commandArgs>","messagePattern":"Dependencies type not implemented: <commandArgs>","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/server/LexicalizedParserServer.java","lineNumber":229,"sourceCode":"  // TODO: when this method throws an exception (for whatever reason)\n  // a waiting client might hang.  There should be some graceful\n  // handling of that.\n  public void handleDependencies(String arg, OutputStream outStream, String commandArgs) \n    throws IOException\n  {\n    Tree tree = parse(arg, false);\n    if (tree == null) {\n      return;\n    }\n    // TODO: this might throw an exception if the parser doesn't support dependencies.  Handle that cleaner?\n    GrammaticalStructure gs = parser.getTLPParams().getGrammaticalStructure(tree, parser.treebankLanguagePack().punctuationWordRejectFilter(), parser.getTLPParams().typedDependencyHeadFinder());\n    Collection<TypedDependency> deps = null;\n    switch (commandArgs.toUpperCase()) {\n    case \"COLLAPSED_TREE\":\n      deps = gs.typedDependenciesCollapsedTree();\n      break;\n    default:\n      throw new UnsupportedOperationException(\"Dependencies type not implemented: \" + commandArgs);\n    }\n    OutputStreamWriter osw = new OutputStreamWriter(outStream, \"utf-8\");\n    for (TypedDependency dep : deps) {\n      osw.write(dep.toString());\n      osw.write(\"\\n\");\n    }\n    osw.flush();\n  }\n\n  /**\n   * Returns the result of applying the parser to arg as a serialized tree.\n   */\n  public void handleTree(String arg, OutputStream outStream) \n    throws IOException\n  {\n    Tree tree = parse(arg, false);\n    if (tree == null) {\n      return;","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/server/LexicalizedParserServer.java#L211-L247","documentation":"LexicalizedParserServer.handleDependencies() only implements the COLLAPSED_TREE dependencies type; any other command argument hits the switch default and throws UnsupportedOperationException. The server exposes just one dependency-output flavor for this endpoint.","triggerScenarios":"Sending a server request 'deps' (or similar) with a commandArgs value other than COLLAPSED_TREE, e.g. 'TREE', 'COLLAPSED', 'BASIC', or a lowercase-variant bug (uppercase conversion is applied, so casing is fine).","commonSituations":"Clients built against newer CoreNLP APIs (which support basic/collapsed/semicolon formats) talking to an older server, or guessing argument names not in the switch.","solutions":["Send exactly COLLAPSED_TREE as the dependencies type argument.","Upgrade both client and server to a CoreNLP version supporting the dependency format you need.","Compute other dependency styles client-side from a parsed tree (typedDependencies in your own code).","Patch/extend handleDependencies in a local fork if you need additional formats."],"exampleFix":"// before\nString resp = client.query(\"deps\", \"basic\", sentence);\n// after\nString resp = client.query(\"deps\", \"COLLAPSED_TREE\", sentence);","handlingStrategy":"validation","validationCode":"if (!\"COLLAPSED_TREE\".equalsIgnoreCase(depsType))\n    throw new IllegalArgumentException(\"Server supports only COLLAPSED_TREE deps type, got: \" + depsType);","typeGuard":null,"tryCatchPattern":"try {\n    String resp = client.query(\"deps\", depsType, sentence);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().startsWith(\"Dependencies type not implemented\")) {\n        // fall back to COLLAPSED_TREE\n    }\n}","preventionTips":["Hard-code the argument as COLLAPSED_TREE.","Derive other dependency styles client-side from the returned tree.","Verify server version before relying on newer dep formats."],"tags":["java","server","unsupported-operation","nlp"],"backgroundTag":"unsupported-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"}