{"record":{"id":"69d218e87c55f8c6","repo":"JuliusBrussee/caveman","slug":"select-missing-option","errorCode":null,"errorMessage":"select: missing option","messagePattern":"select: missing option","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"browse/cdp.go","lineNumber":205,"sourceCode":"\t\tif err := chromedp.Run(runCtx, chromedp.ActionFunc(func(actionCtx context.Context) error {\n\t\t\treturn input.InsertText(req.Text).Do(actionCtx)\n\t\t})); err != nil {\n\t\t\treturn ActionResult{OK: false, Settled: false}, err\n\t\t}\n\t\treturn dispatchedAction(), nil\n\tcase \"select\":\n\t\tif err := d.scrollIntoView(runCtx, target); err != nil {\n\t\t\treturn ActionResult{OK: false, Settled: false}, err\n\t\t}\n\t\tif _, _, err := d.waitActionable(runCtx, target); err != nil {\n\t\t\treturn ActionResult{OK: false, Settled: false}, err\n\t\t}\n\t\toption := req.Option\n\t\tif option == \"\" {\n\t\t\toption = req.Text\n\t\t}\n\t\tif option == \"\" {\n\t\t\treturn ActionResult{OK: false, Settled: false}, errors.New(\"select: missing option\")\n\t\t}\n\t\tif err := d.callOnNode(runCtx, target, fmt.Sprintf(`function(){ const wanted = %s; const options = Array.from(this.options || []); const match = options.find(o => o.value === wanted || o.label === wanted || o.textContent.trim() === wanted); if (!match) { throw new Error(\"option not found\"); } this.value = match.value; this.dispatchEvent(new Event(\"input\", {bubbles:true})); this.dispatchEvent(new Event(\"change\", {bubbles:true})); return true; }`, jsString(option))); err != nil {\n\t\t\treturn ActionResult{OK: false, Settled: false}, err\n\t\t}\n\t\treturn dispatchedAction(), nil\n\tcase \"scroll\":\n\t\tif err := d.scrollIntoView(runCtx, target); err != nil {\n\t\t\treturn ActionResult{OK: false, Settled: false}, err\n\t\t}\n\t\tif _, _, err := d.waitActionable(runCtx, target); err != nil {\n\t\t\treturn ActionResult{OK: false, Settled: false}, err\n\t\t}\n\t\treturn dispatchedAction(), nil\n\tdefault:\n\t\treturn ActionResult{OK: false, Settled: false}, fmt.Errorf(\"unknown action: %s\", req.Action)\n\t}\n}\n","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/browse/cdp.go#L187-L223","documentation":"Returned by the CDPDriver 'select' action when both req.Option and req.Text are empty strings. The driver falls back option := req.Option, then option := req.Text; a select on a <select> element needs a value/label/text to match, so with neither field set the action aborts before touching the page (after scrollIntoView and waitActionable have already passed).","triggerScenarios":"Calling the browser act tool with action=\"select\" and neither option nor text in the request payload; a client that puts the choice in a differently-named field (e.g. 'value') the driver does not read.","commonSituations":"Agent formats a select action from a plan and forgets the target option; MCP client schema drift where the field is named differently across versions; selecting the first option by convention without specifying it.","solutions":["Include the choice: set `option` to the option's value or label, or `text` to its visible text — either is accepted and matched against value, label, and trimmed textContent in order.","Check the exact request field names the driver reads (req.Option, req.Text) if you are building the payload by hand.","Note the target must be an actionable <select> first — but this specific error means the element was fine and only the option string was missing."],"exampleFix":"// before\nact(target: \"s7\", action: \"select\")  // no option\n\n// after\nact(target: \"s7\", action: \"select\", option: \"US-WEST\")\n// or: act(target: \"s7\", action: \"select\", text: \"US West\")","handlingStrategy":"validation","validationCode":"// Go caller-side check before dispatching to the driver\nfunc validSelect(req ActionRequest) bool {\n    return req.Action == \"select\" && (req.Option != \"\" || req.Text != \"\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set `option` (value or label) or `text` on select actions — the driver accepts either.","List a select's options via eval first when unsure of the exact value/label text.","Remember matching order is value, then label, then trimmed textContent."],"tags":["browser","cdp","dom","form","validation"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}