{"record":{"id":"dd9eb841bad6c5fc","repo":"stanfordnlp/CoreNLP","slug":"tag-did-not-end-with","errorCode":null,"errorMessage":"Tag did not end with >","messagePattern":"Tag did not end with >","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/util/XMLUtils.java","lineNumber":1097,"sourceCode":"    public boolean isEndTag;\n\n    /** Whether this is an empty element expressed as a single empty element tag like {@code <p/>}. */\n    public boolean isSingleTag;\n\n    /**\n     * Assumes that String contains an XML tag.\n     *\n     * @param tag String to turn into an XMLTag object\n     */\n    public XMLTag(String tag) {\n      if (tag == null || tag.isEmpty()) {\n        throw new NullPointerException(\"Attempted to parse empty/null tag\");\n      }\n      if (tag.charAt(0) != '<') {\n        throw new IllegalArgumentException(\"Tag did not start with <\");\n      }\n      if (tag.charAt(tag.length() - 1) != '>') {\n        throw new IllegalArgumentException(\"Tag did not end with >\");\n      }\n      text = tag;\n      int begin = 1;\n      if (tag.charAt(1) == '/') {\n        begin = 2;\n        isEndTag = true;\n      } else {\n        isEndTag = false;\n      }\n      int end = tag.length() - 1;\n      if (tag.charAt(tag.length() - 2) == '/') {\n        end = tag.length() - 2;\n        isSingleTag = true;\n      } else {\n        isSingleTag = false;\n      }\n      tag = tag.substring(begin, end);\n      attributes = Generics.newHashMap();","sourceCodeStart":1079,"sourceCodeEnd":1115,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/util/XMLUtils.java#L1079-L1115","documentation":"XMLUtils.XMLTag's constructor throws IllegalArgumentException when the tag string does not end with '>'. Along with the '<' check, this guarantees the constructor only receives bracket-delimited tag text it can parse for name/attributes.","triggerScenarios":"new XMLTag(\"<a href=\\\"x\\\"\") where a trailing '>' was lost to truncation or a line-based splitter cut the tag mid-way.","commonSituations":"Reading XML wrapped across lines and splitting on newline, cutting tags in half; truncated files or streamed input buffered mid-tag.","solutions":["Ensure the complete '<' ... '>' token is passed; buffer input until the closing '>' is available.","Validate with tag.endsWith(\">\") before construction.","Fix upstream splitting logic to split on tag boundaries, not line breaks.","Catch IllegalArgumentException and reassemble/skip the malformed fragment."],"exampleFix":"// before\nfor (String line : xml.split(\"\\n\")) new XMLTag(line.trim()); // may cut tags\n// after\nMatcher m = Pattern.compile(\"<[^>]*>\").matcher(xml);\nwhile (m.find()) new XMLTag(m.group());","handlingStrategy":"type-guard","validationCode":"if (tag == null || !tag.endsWith(\">\")) throw new IllegalArgumentException(\"truncated tag: \" + tag);","typeGuard":"static boolean isCompleteTag(String s) {\n  return s != null && s.length() >= 2 && s.endsWith(\">\") && s.startsWith(\"<\");\n}","tryCatchPattern":"try {\n  new XMLTag(token);\n} catch (IllegalArgumentException e) {\n  buffer.append(token); // wait for the rest of the tag\n}","preventionTips":["Buffer streamed input until the closing '>' arrives.","Split XML on tag boundaries, not newlines.","Use a regex like <[^>]*> to extract complete tags."],"tags":["java","xml","parsing","format"],"backgroundTag":"invalid-argument-format","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}