{"record":{"id":"a6f88599aa059e30","repo":"wavetermdev/waveterm","slug":"doctype-not-supported","errorCode":null,"errorMessage":"doctype not supported","messagePattern":"doctype not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/vdom/vdom_html.go","lineNumber":385,"sourceCode":"\t\t\t\tappendChildToStack(elemStack, &VDomElem{Tag: WaveTextTag, Props: map[string]any{\"text\": binding}})\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\telem := tokenToElem(token, params)\n\t\t\tappendChildToStack(elemStack, elem)\n\t\tcase htmltoken.TextToken:\n\t\t\tif token.Data == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\ttextStr := processTextStr(token.Data)\n\t\t\tif textStr == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\telem := TextElem(textStr)\n\t\t\tappendChildToStack(elemStack, &elem)\n\t\tcase htmltoken.CommentToken:\n\t\t\tcontinue\n\t\tcase htmltoken.DoctypeToken:\n\t\t\ttokenErr = errors.New(\"doctype not supported\")\n\t\t\tbreak outer\n\t\tcase htmltoken.ErrorToken:\n\t\t\tif iter.Err() == io.EOF {\n\t\t\t\tbreak outer\n\t\t\t}\n\t\t\ttokenErr = iter.Err()\n\t\t\tbreak outer\n\t\t}\n\t}\n\tif tokenErr != nil {\n\t\terrTextElem := TextElem(tokenErr.Error())\n\t\tappendChildToStack(elemStack, &errTextElem)\n\t}\n\trtn := finalizeStack(elemStack)\n\tfixupStyleAttributes(rtn, params, nil)\n\treturn rtn\n}\n","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/vdom/vdom_html.go#L367-L403","documentation":"vdom.Bind's HTML tokenizer encountered a <!DOCTYPE ...> declaration, which the minimal bind-HTML grammar does not support. Bind expects a plain fragment of HTML (elements, text, comments, bind tags) — a doctype means a full HTML document was passed where only a fragment is expected, so parsing stops with this error.","triggerScenarios":"Passing an entire HTML document including its <!DOCTYPE html> prolog to vdom.Bind instead of just the body/fragment content.","commonSituations":"Loading .html files saved from browsers or exported documents and feeding them whole into Bind; server-rendering pipelines that hand the full document to the VDOM layer; misconfigured template loaders that do not strip the doctype.","solutions":["Strip the <!DOCTYPE ...> declaration (and usually <html>/<head>/<body> wrappers) before passing markup to vdom.Bind.","Configure your template loader to read only the body fragment of HTML documents.","Convert full documents upstream with an HTML parser (e.g. golang.org/x/net/html) and pass Bind only the extracted fragment."],"exampleFix":"// before\ncontent, _ := os.ReadFile(\"page.html\") // includes <!DOCTYPE html>\nelem, err := vdom.Bind(string(content), params)\n// after\ncontent, _ := os.ReadFile(\"page.html\")\nfragment := stripDoctypeAndBodyExtract(string(content)) // remove <!DOCTYPE ...> prolog\nelem, err := vdom.Bind(fragment, params)","handlingStrategy":"validation","validationCode":"if strings.HasPrefix(strings.TrimSpace(html), \"<!DOCTYPE\") || strings.HasPrefix(strings.ToLower(strings.TrimSpace(html)), \"<!doctype\") {\n    return fmt.Errorf(\"pass a document fragment, not a full HTML document, to vdom.Bind\")\n}","typeGuard":null,"tryCatchPattern":"elem, err := vdom.Bind(html, params)\nif err != nil && strings.Contains(err.Error(), \"doctype not supported\") {\n    return fmt.Errorf(\"strip the <!DOCTYPE> prolog before binding: %w\", err)\n}\nif err != nil {\n    return err\n}","preventionTips":["Feed vdom.Bind fragments, never full HTML documents.","Strip DOCTYPE and html/head/body wrappers at the template-loader level.","When exporting from browsers/tools, extract only the body content.","Add a loader-level test asserting no 'doctype' prefix reaches Bind."],"tags":["go","html","doctype","vdom","parse-error"],"backgroundTag":"unsupported-html-construct","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}