{"record":{"id":"443108ac55cfd19a","repo":"golang/go","slug":"parsing-s-v-443108","errorCode":null,"errorMessage":"parsing %s: %v","messagePattern":"parsing (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/vcs/vcs.go","lineNumber":1015,"sourceCode":"\tif err != nil {\n\t\tmsg := \"https fetch: %v\"\n\t\tif security == web.Insecure {\n\t\t\tmsg = \"http/\" + msg\n\t\t}\n\t\treturn nil, fmt.Errorf(msg, err)\n\t}\n\tbody := resp.Body\n\tdefer body.Close()\n\timports, err := parseMetaGoImports(body, mod)\n\tif len(imports) == 0 {\n\t\tif respErr := resp.Err(); respErr != nil {\n\t\t\t// If the server's status was not OK, prefer to report that instead of\n\t\t\t// an XML parse error.\n\t\t\treturn nil, respErr\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parsing %s: %v\", importPath, err)\n\t}\n\t// Find the matched meta import.\n\tmmi, err := matchGoImport(imports, importPath)\n\tif err != nil {\n\t\tif _, ok := err.(ImportMismatchError); !ok {\n\t\t\treturn nil, fmt.Errorf(\"parse %s: %v\", url, err)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"parse %s: no go-import meta tags (%s)\", resp.URL, err)\n\t}\n\tif cfg.BuildV {\n\t\tlog.Printf(\"get %q: found meta tag %#v at %s\", importPath, mmi, url)\n\t}\n\t// If the import was \"uni.edu/bob/project\", which said the\n\t// prefix was \"uni.edu\" and the RepoRoot was \"evilroot.com\",\n\t// make sure we don't trust Bob and check out evilroot.com to\n\t// \"uni.edu\" yet (possibly overwriting/preempting another\n\t// non-evil student). Instead, first verify the root and see\n\t// if it matches Bob's claim.","sourceCodeStart":997,"sourceCodeEnd":1033,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/vcs/vcs.go#L997-L1033","documentation":"Emitted by repoRootForImportDynamic when parseMetaGoImports fails to tokenize the fetched HTML body for <meta name=\"go-import\"> tags and produced zero candidate imports. The %s is the import path; %v is the HTML parse error. Distinct from a missing-tags error (1150): this is a parser failure.","triggerScenarios":"The server returns HTTP 200 with malformed HTML or a body the meta-tag parser cannot tokenize (unclosed tags, invalid encoding, non-UTF-8 bytes). The resp.Err() check is skipped because zero imports were produced.","commonSituations":"Vanity server returning an HTML error/login page in the body with status 200; CDN injecting script that breaks the tokenizer; server returning JSON or binary instead of text/html; charset mislabeling.","solutions":["Fetch the URL manually (curl 'https://<importPath>?go-get=1') and confirm it is well-formed HTML containing the go-import meta tag","Ensure the server returns Content-Type: text/html; charset=utf-8","Check the server isn't returning a login/redirect HTML page or a WAF challenge","Validate the body passes an HTML parser (e.g. x/net/html)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate the vanity page parses and contains a go-import meta tag\nimport (\n  \"io\"\n  \"net/http\"\n  \"strings\"\n  \"golang.org/x/net/html\"\n)\nfunc hasGoImport(u string) (bool, error) {\n  r, err := http.Get(u + \"?go-get=1\")\n  if err != nil { return false, err }\n  defer r.Body.Close()\n  doc, err := html.Parse(r.Body)\n  if err != nil { return false, err }\n  var walk func(*html.Node) bool\n  walk = func(n *html.Node) bool {\n    if n.Type == html.ElementNode && n.Data == \"meta\" {\n      for _, a := range n.Attr { if a.Key == \"name\" && a.Val == \"go-import\" { return true } }\n    }\n    for c := n.FirstChild; c != nil; c = c.NextSibling { if walk(c) { return true } }\n    return false\n  }\n  _ = io.EOF\n  return walk(doc), nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Smoke-test vanity pages with curl '?go-get=1' after every server change","Return Content-Type: text/html and valid UTF-8 from the vanity endpoint","Don't put JSON or login HTML at the go-get endpoint"],"tags":["go","modules","vcs","html-parsing"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}