{"record":{"id":"e8c3ab18095a1971","repo":"jhy/jsoup","slug":"could-not-parse-query-s-unknown-node-type","errorCode":null,"errorMessage":"Could not parse query '%s': unknown node type '::%s'","messagePattern":"Could not parse query '(.+?)': unknown node type '::(.+?)'","errorType":"exception","errorClass":"Selector.SelectorParseException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/jsoup/select/QueryParser.java","lineNumber":292,"sourceCode":"                left = new NodeEvaluator.InstanceType(Node.class, pseudo);\n                break;\n            case \"leafnode\":\n                left = new NodeEvaluator.InstanceType(LeafNode.class, pseudo);\n                break;\n            case \"text\":\n                left = new NodeEvaluator.InstanceType(TextNode.class, pseudo);\n                break;\n            case \"comment\":\n                left = new NodeEvaluator.InstanceType(Comment.class, pseudo);\n                break;\n            case \"data\":\n                left = new NodeEvaluator.InstanceType(DataNode.class, pseudo);\n                break;\n            case \"cdata\":\n                left = new NodeEvaluator.InstanceType(CDataNode.class, pseudo);\n                break;\n            default:\n                throw new Selector.SelectorParseException(\n                    \"Could not parse query '%s': unknown node type '::%s'\", query, pseudo);\n        }\n\n        // Handle following subclasses in node context (like ::comment:contains())\n        Evaluator right;\n        while ((right = parseSubclass()) != null) {\n            left = and(left, right);\n        }\n\n        inNodeContext = false;\n        return left;\n    }\n\n    private Evaluator byId() {\n        String id = tq.consumeCssIdentifier();\n        Validate.notEmpty(id);\n        return new Evaluator.Id(id);\n    }","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/jhy/jsoup/blob/9851ac5d9c576c6888910b5a51a2362bbc978959/src/main/java/org/jsoup/select/QueryParser.java#L274-L310","documentation":"jsoup's node selector parser (:: syntax, e.g. ::text, ::comment, ::data, ::cdata) threw because the identifier after '::' is not one of the known node types. The Selector.SelectorParseException names the query and the unknown node type. Only a fixed set of node-type keywords is supported.","triggerScenarios":"A selector containing '::unknownType', e.g. doc.select(\"div::elements\") or a typo like doc.select(\"::coment\"). Parsed in QueryParser.parseNodeSelector via parseSubclass.","commonSituations":"Typos in node selectors; guessing at supported ::node names; porting queries written for other selector engines with different node pseudo-syntax.","solutions":["Use a supported node type: ::text, ::comment, ::data, ::cdata","Fix typos in the node selector (e.g. '::coment' -> '::comment')","Combine node selectors with subclasses if needed, e.g. '::comment:contains(foo)'","Use Class-based selection, e.g. selectNodes(query, TextNode.class) with ::text"],"exampleFix":"// before\nList<Comment> c = doc.selectNodes(\"div::coment\", Comment.class);\n// after\nList<Comment> c = doc.selectNodes(\"div::comment\", Comment.class);","handlingStrategy":"validation","validationCode":"if (!java.util.regex.Pattern.compile(\"::(text|comment|data|cdata)\").matcher(query).find() && query.contains(\"::\")) {\n    throw new IllegalArgumentException(\"Unknown ::node type in: \" + query);\n}","typeGuard":"boolean isKnownNodeSelector(String q) { return q.matches(\".*::(text|comment|data|cdata).*\"); }","tryCatchPattern":"try {\n    List<TextNode> nodes = doc.selectNodes(query, TextNode.class);\n} catch (Selector.SelectorParseException e) {\n    log.error(\"Unknown node type in '{}'\", query);\n    throw e;\n}","preventionTips":["Restrict :: selectors to text, comment, data, cdata","Combine node selectors with subclasses like ::comment:contains(...)","Add selector lint tests for generated queries"],"tags":["jsoup","css-selector","node-selector","parse-error"],"backgroundTag":"invalid-enum-value","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"}