{"record":{"id":"6f2ce87aa849e8ac","repo":"stanfordnlp/CoreNLP","slug":"tag-did-not-start-with","errorCode":null,"errorMessage":"Tag did not start with <","messagePattern":"Tag did not start with <","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/util/XMLUtils.java","lineNumber":1094,"sourceCode":"    public Map<String,String> attributes;\n\n    /** Whether this is an ending tag or not. */\n    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;","sourceCodeStart":1076,"sourceCodeEnd":1112,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/util/XMLUtils.java#L1076-L1112","documentation":"XMLUtils.XMLTag's constructor throws IllegalArgumentException when the tag string does not begin with '<'. The constructor assumes well-formed bracketed tags, and this check rejects tokens that clearly are not XML tags.","triggerScenarios":"new XMLTag(\"name attr=\\\"x\\\"\") or passing plain text content / a tag body without the opening bracket extracted from a document.","commonSituations":"Custom XML splitters that strip the '<' during tokenizing; passing escaped or HTML-entity-encoded text to XMLTag.","solutions":["Include the leading '<' in the string passed to XMLTag (e.g. prepend if missing after verifying the fragment is a tag).","Fix the upstream tokenizer to keep the bracket characters.","Validate with tag.startsWith(\"<\") before construction.","Catch IllegalArgumentException and treat the token as non-tag text."],"exampleFix":"// before\nnew XMLTag(\"a href=\\\"x\\\">\"); // throws\n// after\nString tok = \"a href=\\\"x\\\">\";\nif (!tok.startsWith(\"<\")) tok = \"<\" + tok;\nnew XMLTag(tok);","handlingStrategy":"type-guard","validationCode":"if (tag == null || !tag.startsWith(\"<\")) throw new IllegalArgumentException(\"not a tag: \" + tag);","typeGuard":"static boolean startsWithTag(String s) {\n  return s != null && s.startsWith(\"<\");\n}","tryCatchPattern":"try {\n  new XMLTag(token);\n} catch (IllegalArgumentException e) {\n  log.warning(\"malformed tag token: \" + token);\n}","preventionTips":["Keep '<' and '>' in extracted tag tokens.","Unit-test the tokenizer on tags containing '>'-free attributes.","Treat non-tag text with a separate code path."],"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-15T23:17:13.987Z"}