{"record":{"id":"f4a26e01e3346c72","repo":"grafana/k6","slug":"unpacking-selected-options-w","errorCode":null,"errorMessage":"unpacking selected options: %w","messagePattern":"unpacking selected options: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":1429,"sourceCode":"\n\treturn nil\n}\n\n// SelectOption selects the options matching the given values.\nfunc (h *ElementHandle) SelectOption(values []any, opts *ElementHandleBaseOptions) ([]string, error) {\n\tselectOption := func(apiCtx context.Context, handle *ElementHandle) (any, error) {\n\t\treturn handle.selectOption(apiCtx, values)\n\t}\n\tselectOptionAction := h.newAction(\n\t\t[]string{}, selectOption, opts.Force, withRetry, opts.NoWaitAfter, opts.Timeout,\n\t)\n\tselectedOptions, err := call(h.ctx, selectOptionAction, opts.Timeout)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"selecting options: %w\", err)\n\t}\n\tvar returnVal []string\n\tif err := convert(selectedOptions, &returnVal); err != nil {\n\t\treturn nil, fmt.Errorf(\"unpacking selected options: %w\", err)\n\t}\n\n\tapplySlowMo(h.ctx)\n\n\treturn returnVal, nil\n}\n\n// SelectText selects the text of the element.\nfunc (h *ElementHandle) SelectText(opts *ElementHandleBaseOptions) error {\n\tselectText := func(apiCtx context.Context, handle *ElementHandle) (any, error) {\n\t\treturn nil, handle.selectText(apiCtx)\n\t}\n\tselectTextAction := h.newAction(\n\t\t[]string{}, selectText, opts.Force, withRetry, opts.NoWaitAfter, opts.Timeout,\n\t)\n\tif _, err := call(h.ctx, selectTextAction, opts.Timeout); err != nil {\n\t\treturn fmt.Errorf(\"selecting text: %w\", err)\n\t}","sourceCodeStart":1411,"sourceCodeEnd":1447,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/element_handle.go#L1411-L1447","documentation":"ElementHandle.SelectOption() succeeded at the protocol level but converting the returned selected-option list into []string failed (element_handle.go:1429). The convert() failure means the injected script returned an unexpected shape — an internal invariant break, not bad user input (bad values fail earlier with 'selecting options').","triggerScenarios":"A chromium/CDP deviation or k6 browser-module bug producing a non-string-array result from the select action; context destroyed between selection and value marshalling.","commonSituations":"Rare; correlated with chromium version changes or module regressions rather than with script logic.","solutions":["Upgrade k6 to the latest release","If reproducible, file a k6 issue with the minimal select element and script","Retry once — context-teardown races produce it transiently","Read back state via inputValue()/evaluated DOM if you need the selection deterministically"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return await el.selectOption('us'); }\ncatch (e) { if (/unpacking selected options/.test(e.message)) { return await el.evaluate(n => Array.from(n.selectedOptions).map(o => o.value)); } throw e; }","preventionTips":["Keep k6 updated — this is a marshalling invariant, not script logic","Fall back to evaluating selectedOptions in the page when it fires","Report reproducible cases upstream"],"tags":["browser","internal","invariant","select"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}