{"record":{"id":"63ec13c670b5b6f7","repo":"stanfordnlp/CoreNLP","slug":"error-n-s-ninput-n-s-noutput-n-s-63ec13","errorCode":null,"errorMessage":"error:\\n%s\\ninput:\\n%s\\noutput:\\n%s","messagePattern":"error:\\\\n(.+?)\\\\ninput:\\\\n(.+?)\\\\noutput:\\\\n(.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/time/HeidelTimeAnnotator.java","lineNumber":141,"sourceCode":"    SystemUtils.run(process, outputWriter, null);\n    String output = outputWriter.getBuffer().toString();\n    Pattern docClose = Pattern.compile(\"</DOC>.*\", Pattern.DOTALL);\n    output = docClose.matcher(output).replaceAll(\"</DOC>\").replaceAll(\"<!DOCTYPE TimeML SYSTEM \\\"TimeML.dtd\\\">\",\"\"); //TODO TimeML.dtd? FileNotFoundException if we leave it in\n    Pattern badNestedTimex = Pattern.compile(Pattern.quote(\"<T</TIMEX3>IMEX3\"));\n    output = badNestedTimex.matcher(output).replaceAll(\"</TIMEX3><TIMEX3\");\n    Pattern badNestedTimex2 = Pattern.compile(Pattern.quote(\"<TI</TIMEX3>MEX3\"));\n    output = badNestedTimex2.matcher(output).replaceAll(\"</TIMEX3><TIMEX3\");\n    //output = output.replaceAll(\"\\\\n\\\\n<TimeML>\\\\n\\\\n\",\"<TimeML>\");\n    // These tags are needed for the xml to operate\n    //output = output.replaceAll(\"<TimeML>\", \"\");\n    //output = output.replaceAll(\"</TimeML>\", \"\");\n\n    // parse the HeidelTime output\n    Element outputXML;\n    try {\n      outputXML = XMLUtils.parseElement(output);\n    } catch (Exception ex) {\n      throw new RuntimeException(String.format(\"error:\\n%s\\ninput:\\n%s\\noutput:\\n%s\",\n              ex, IOUtils.slurpFile(inputFile), output), ex);\n    }\n    inputFile.delete();\n\n    // get Timex annotations\n    List<CoreMap> timexAnns = toTimexCoreMaps(outputXML, document);\n    document.set(TimeAnnotations.TimexAnnotations.class, timexAnns);\n    if (outputResults) {\n      System.out.println(timexAnns);\n    }\n\n    // align Timex annotations to sentences\n    int timexIndex = 0;\n    for (CoreMap sentence: document.get(CoreAnnotations.SentencesAnnotation.class)) {\n      int sentBegin = beginOffset(sentence);\n      int sentEnd = endOffset(sentence);\n\n      // skip times before the sentence","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/time/HeidelTimeAnnotator.java#L123-L159","documentation":"After running HeidelTime, its XML output is parsed with XMLUtils.parseElement; if parsing fails for any reason, the annotator throws a RuntimeException whose message embeds the exception, the raw input file contents, and HeidelTime's raw output, chaining the original cause. It indicates HeidelTime produced malformed, empty, or error output instead of valid Timex3 XML.","triggerScenarios":"HeidelTime crashes or emits an error message (e.g. missing tree tagger models, bad language/resource config) so 'output' is not well-formed XML; output truncated or empty because the external process failed.","commonSituations":"Wrong heideltime language/resource properties causing the binary to print usage/errors; missing TreeTagger installation; locale or encoding problems corrupting the XML; an older HeidelTime version outputting a different format.","solutions":["Read the embedded 'error:' cause and 'output:' in the message to see what HeidelTime actually printed.","Fix HeidelTime configuration (language, resource path, tree tagger binaries) so it runs successfully.","Run HeidelTime manually on the included inputFile contents to reproduce and diagnose.","Validate that output is non-empty well-formed XML before calling toTimexCoreMaps if wrapping the annotator."],"exampleFix":"// before (debugging)\nthrow new RuntimeException(String.format(\"error:\\n%s\\ninput:\\n%s\\noutput:\\n%s\", ex, in, out), ex);\n// after: fix root cause, e.g. supply resource path\nprops.setProperty(\"heideltime.path\", \"/opt/heideltime/heideltime.sh\");\nprops.setProperty(\"heideltime.language\", \"english\");","handlingStrategy":"try-catch","validationCode":"// Sanity-check the HeidelTime output before it reaches XML parsing\nif (output == null || output.trim().isEmpty() || !output.trim().startsWith(\"<\")) {\n  throw new IllegalStateException(\"HeidelTime returned non-XML output: \" + output);\n}","typeGuard":"boolean looksLikeXml(String s) {\n  return s != null && s.trim().startsWith(\"<\") && s.trim().endsWith(\">\");\n}","tryCatchPattern":"try {\n  heidelTimeAnnotator.annotate(annotation);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"error:\")) {\n    logger.log(Level.SEVERE, \"HeidelTime produced invalid XML; output was:\\n\" + e.getMessage(), e);\n  } else { throw e; }\n}","preventionTips":["Verify HeidelTime's language/resource/TreeTagger configuration before deployment.","Run HeidelTime manually once on a sample doc to confirm it emits well-formed Timex3 XML.","Log HeidelTime's raw stdout/stderr in your wrapper to shorten diagnosis."],"tags":["java","xml-parse","external-process","heideltime"],"backgroundTag":"xml-parse-error","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"}