{"record":{"id":"3bc50384a9266682","repo":"projectdiscovery/katana","slug":"captcha-solve-w","errorCode":null,"errorMessage":"captcha solve: %w","messagePattern":"captcha solve: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/engine/headless/captcha/captcha.go","lineNumber":51,"sourceCode":"\n\tinfo, err := Identify(page)\n\tif err != nil {\n\t\tgologger.Debug().Msgf(\"captcha identification failed: %s\", err)\n\t}\n\n\tif info == nil {\n\t\treturn false, nil\n\t}\n\n\treturn h.solveCaptcha(ctx, page, info)\n}\n\nfunc (h *Handler) solveCaptcha(ctx context.Context, page *rod.Page, info *Info) (bool, error) {\n\tgologger.Debug().Msgf(\"captcha detected: provider=%s sitekey=%s url=%s\", info.Provider, info.SiteKey, info.PageURL)\n\n\tsolution, err := h.solver.Solve(ctx, info)\n\tif err != nil {\n\t\treturn true, fmt.Errorf(\"captcha solve: %w\", err)\n\t}\n\n\tgologger.Debug().Msgf(\"captcha solved, injecting token: provider=%s\", solution.Provider)\n\n\tif err := injectToken(page, solution); err != nil {\n\t\treturn true, fmt.Errorf(\"captcha inject: %w\", err)\n\t}\n\n\treturn true, nil\n}\n\nfunc injectToken(page *rod.Page, solution *Solution) error {\n\tjs, err := injectionScript(solution.Provider)\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = page.Eval(js, solution.Token)\n\treturn err","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/projectdiscovery/katana/blob/e3e742739c3746f085943ce918fb4e2b8daf6fe6/pkg/engine/headless/captcha/captcha.go#L33-L69","documentation":"solveCaptcha delegates to the configured solver's Solve; any failure there (timeout, CapSolver API error, missing token, network error) is wrapped with this prefix. It means a captcha was detected on the page and solving was attempted, but no usable token was produced.","triggerScenarios":"Called by HandleIfCaptcha after detection identifies a captcha; wraps every error the solver returns, including capsolver timeouts/errors, missing tokens, unsupported providers, and HTTP failures.","commonSituations":"Expired/invalid solver API key; CapSolver outage; captcha type the solver cannot handle; crawl context cancelled mid-solve; low balance.","solutions":["Unwrap the chain (%w) to find the root cause (timeout vs API error vs missing token)","Validate the solver API key and balance before the crawl","Raise the context deadline (solve budget is 120s)","Configure a fallback solver or disable captcha solving for targets that reliably fail","Retry the page once with a fresh context"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if handler == nil {\n\t// captcha solving not configured; skip HandleIfCaptcha\n}","typeGuard":null,"tryCatchPattern":"handled, err := handler.HandleIfCaptcha(ctx, page, html)\nif err != nil {\n\tlog.Printf(\"captcha handling failed (continuing): %v\", err)\n\t// decide: skip target or proceed unsolved\n}","preventionTips":["Pre-flight validate solver credentials","Set generous context deadlines","Unwrap the %w chain to route timeouts vs API errors differently","Have a fallback strategy for pages where solving fails"],"tags":["captcha","capsolver","error-wrapping"],"backgroundTag":"captcha-solve-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"}