{"record":{"id":"2ae777cb908fe416","repo":"grafana/k6","slug":"parsing-element-index-q-for-selector-q-w","errorCode":null,"errorMessage":"parsing element index %q for selector %q: %w","messagePattern":"parsing element index %q for selector %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":1308,"sourceCode":"\tprops, err := handles.GetProperties()\n\tif err != nil {\n\t\t// GetProperties has a rich error already, so we don't need to wrap it.\n\t\treturn nil, err //nolint:wrapcheck\n\t}\n\n\ttype indexedElem struct {\n\t\tindex int\n\t\telem  *ElementHandle\n\t}\n\n\tindexedElems := make([]indexedElem, 0, len(props))\n\tfor key, prop := range props {\n\t\tif el := prop.AsElement(); el != nil {\n\t\t\t// DOM elements are stored with numeric indices (\"0\", \"1\", \"2\", ...)\n\t\t\t// per JavaScript's array-like object specification.\n\t\t\tidx, err := strconv.Atoi(key)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing element index %q for selector %q: %w\", key, selector, err)\n\t\t\t}\n\t\t\tindexedElems = append(indexedElems, indexedElem{index: idx, elem: el})\n\t\t} else if err := prop.Dispose(); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"disposing property while querying all selectors %q: %w\", selector, err)\n\t\t}\n\t}\n\n\tslices.SortFunc(indexedElems, func(a, b indexedElem) int {\n\t\treturn cmp.Compare(a.index, b.index)\n\t})\n\n\tels := make([]*ElementHandle, 0, len(indexedElems))\n\tfor _, ie := range indexedElems {\n\t\tels = append(els, ie.elem)\n\t}\n\n\treturn els, nil\n}","sourceCodeStart":1290,"sourceCodeEnd":1326,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/element_handle.go#L1290-L1326","documentation":"Returned by ElementHandle.queryAll while iterating the properties of the query-result handle: a property key that maps to an element is expected to be a numeric index ('0','1',...), but strconv.Atoi failed for the given key. Indicates the injected script returned an object whose element-valued properties are not numerically indexed — an internal contract violation, not bad user input (the selector parsed fine).","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/element_handle.go:1308 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Report as a k6 browser module bug with the selector and page that triggered it","Retry with a different selector as a workaround","Ensure page scripts do not tamper with array indices of results"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}