{"record":{"id":"1975eddc20baef31","repo":"jhy/jsoup","slug":"queue-did-not-match-expected-sequence","errorCode":null,"errorMessage":"Queue did not match expected sequence","messagePattern":"Queue did not match expected sequence","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/jsoup/parser/TokenQueue.java","lineNumber":118,"sourceCode":"    }\n\n    /**\n     Test if the queue matches a tag word character (letter or digit).\n     @return if matches a word character\n     */\n    public boolean matchesWord() {\n        return Character.isLetterOrDigit(reader.current());\n    }\n\n    /**\n     Consumes the supplied sequence of the queue, case-insensitively. If the queue does not start with the supplied\n     sequence, will throw an illegal state exception -- but you should be running match() against that condition.\n\n     @param seq sequence to remove from head of queue.\n     */\n    public void consume(String seq) {\n        boolean found = reader.matchConsumeIgnoreCase(seq);\n        if (!found) throw new IllegalStateException(\"Queue did not match expected sequence\");\n    }\n\n    /**\n     Pulls a string off the queue, up to but exclusive of the match sequence, or to the queue running out.\n     @param seq String to end on (and not include in return, but leave on queue). <b>Case-sensitive.</b>\n     @return The matched data consumed from queue.\n     */\n    public String consumeTo(String seq) {\n        return reader.consumeTo(seq);\n    }\n\n    /**\n     Consumes to the first sequence provided, or to the end of the queue. Leaves the terminator on the queue.\n     @param seq any number of terminators to consume to. <b>Case-insensitive.</b>\n     @return consumed string\n     */\n    public String consumeToAny(String... seq) {\n        StringBuilder sb = StringUtil.borrowBuilder();","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/jhy/jsoup/blob/9851ac5d9c576c6888910b5a51a2362bbc978959/src/main/java/org/jsoup/parser/TokenQueue.java#L100-L136","documentation":"Thrown by TokenQueue.consume(String) when the queue's head does not start with the requested sequence. It is a fail-fast variant of a failed match: the caller skipped the required matches(seq) pre-check (or ignored its result), so consume would otherwise silently desynchronize the parse. The faulty input is the remaining query/HTML text at the reader's current position.","triggerScenarios":"Thrown at src/main/java/org/jsoup/parser/TokenQueue.java:118 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Guard the call with a positive match (e.g. matchChained(seq)) before consuming, as the javadoc requires.","Use a non-throwing matcher such as matchesIgnoreCase() and handle the negative branch explicitly.","If the sequence is optional, check matches() first and only consume on a positive match."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9851ac5d9c576c6888910b5a51a2362bbc978959","analyzedAt":"2026-09-08T15:22:04.931Z","contentChangedAt":"2026-09-08T15:22:04.931Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}