{"record":{"id":"fa9440f9b5ffa9d5","repo":"projectdiscovery/katana","slug":"could-not-get-links","errorCode":null,"errorMessage":"could not get links","messagePattern":"could not get links","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/engine/headless/browser/element.go","lineNumber":114,"sourceCode":"\t\t}\n\n\t\thash := button.Hash()\n\t\tbutton.MD5Hash = hash\n\n\t\tif _, found := unique[hash]; found {\n\t\t\tcontinue\n\t\t}\n\t\tunique[hash] = struct{}{}\n\t\tnavigations = append(navigations, &types.Action{\n\t\t\tType:    types.ActionTypeLeftClick,\n\t\t\tElement: button,\n\t\t})\n\t}\n\n\tscopeValidator := b.launcher.ScopeValidator()\n\tlinks, err := b.GetAllElements(linksCSSSelector)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"could not get links\")\n\t}\n\tinfo, err := b.Info()\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"could not get page info\")\n\t}\n\tfor _, link := range links {\n\t\thref := link.Attributes[\"href\"]\n\t\tif href == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tresolvedHref, err := resolveURL(info.URL, href)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tu, err := url.Parse(resolvedHref)\n\t\tif err != nil {","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/projectdiscovery/katana/blob/e3e742739c3746f085943ce918fb4e2b8daf6fe6/pkg/engine/headless/browser/element.go#L96-L132","documentation":"Wrapper error from FindNavigations when b.GetAllElements(linksCSSSelector) (selector \"a\") fails while enumerating anchor elements. GetAllElements runs the selector in the page via window.getAllElements over CDP; failure is either the eval erroring (context gone, tab closed) or the result failing to unmarshal into []*types.HTMLElement. Link discovery is aborted for the page.","triggerScenarios":"1) Execution context invalidated by an in-page navigation triggered between the earlier discovery steps. 2) Renderer/tab closed or crashed. 3) Missing window.getAllElements injection on this document. 4) Unexpected JSON shape from the eval.","commonSituations":"Crawling sites with instant client-side redirects (meta refresh/JS), error pages with no proper DOM, resource-constrained CI runs where Chrome tabs get killed.","solutions":["Ensure the page has finished loading before discovery (wait for load events)","Retry once; context-destroyed errors are transient","Check that injected init scripts (window.getAllElements etc.) run for every document, including iframes/new documents","Update katana to get hardened eval error handling"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// verify eval pipeline works with a cheap call first\nif _, err := page.GetAllElements(\"body\"); err != nil { return fallbackToHTTPCrawl(page) }","typeGuard":"func evalHealthy(p *browser.BrowserPage) bool {\n    _, err := p.GetAllElements(\"html\")\n    return err == nil\n}","tryCatchPattern":"navs, err := page.FindNavigations()\nif err != nil {\n    logger.Warn(\"link discovery failed\", slog.String(\"error\", err.Error()))\n    return nil // continue crawling other pages\n}","preventionTips":["Confirm page loaded and stable before discovery","Fall back to non-headless link extraction for broken pages","Update katana for hardened eval marshaling","Skip pages whose execution context is destroyed"],"tags":["headless-browser","cdp-eval","crawl"],"backgroundTag":"cdp-evaluation-failed","analyzedSha":"e3e742739c3746f085943ce918fb4e2b8daf6fe6","analyzedAt":"2026-09-03T14:55:13.248Z","contentChangedAt":"2026-09-03T14:55:13.248Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}