{"record":{"id":"3cb3ea3900438771","repo":"SeleniumHQ/selenium","slug":"name-field-name-expected-field-list-a-l","errorCode":null,"errorMessage":"#{name}##{field.name} expected #{field.list ? 'a list' : 'a single value'}, got #{raw.inspect}","messagePattern":"#(.+?)##(.+?) expected #(.+?), got #(.+?)","errorType":"exception","errorClass":"Error::SerializationError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/bidi/serialization/record.rb","lineNumber":271,"sourceCode":"\n            # Reads a ref-typed value into its class. A `scalar` position is an inline union with\n            # a scalar arm collapsed onto its union ref (a map's string keys): a non-object leaf\n            # passes through instead of being handed to the object_only union, but only when it\n            # matches the arm's primitive (+scalar+ carries it). A list recurses per element.\n            def read_ref(field, raw)\n              klass = (@refs ||= {})[field.name] ||= Protocol.const_get(field.ref)\n              return read_list(field, raw, klass) if field.list\n\n              field.scalar && !raw.is_a?(::Hash) ? scalar_value(field, raw) : klass.from_json(raw)\n            end\n\n            # A declared list must arrive as an array; a scalar-shaped field (enum or ref, not a\n            # list) must not. An opaque field carries no shape descriptor, so it passes through.\n            def check_shape(field, raw)\n              return if field.list == raw.is_a?(::Array)\n              return unless field.list || field.enum || field.ref\n\n              raise Error::SerializationError,\n                    \"#{name}##{field.name} expected #{field.list ? 'a list' : 'a single value'}, got #{raw.inspect}\"\n            end\n\n            # Ruby classes a checkable primitive admits. `number` is any Numeric (JSON has one\n            # number type); `integer` requires an Integer — a browser emits `5`, not `5.0`, for an\n            # integer (JS has no int/float split), so this rarely false-positives yet still rejects\n            # a genuine non-integer like 1.5. A field with no primitive descriptor is left unchecked.\n            PRIMITIVE_TYPES = {\n              'string' => [::String], 'boolean' => [::TrueClass, ::FalseClass],\n              'number' => [::Numeric], 'integer' => [::Integer]\n            }.freeze\n\n            def check_primitive(field, raw)\n              expected = PRIMITIVE_TYPES[field.primitive]\n              return if expected.nil? || expected.any? { |type| raw.is_a?(type) }\n\n              raise Error::SerializationError, \"#{name}##{field.name} expected #{field.primitive}, got #{raw.inspect}\"\n            end","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/bidi/serialization/record.rb#L253-L289","documentation":"check_shape validates the JSON container shape of a BiDi field: a field declared as a list must arrive as a JSON array, and a non-list scalar/enum/ref field must NOT arrive as an array. A mismatch raises Error::SerializationError. Opaque fields (no shape descriptor) pass through unchecked.","triggerScenarios":"Browser sends a JSON array for a field the schema types as a single value, or a single value/object for a field typed as a list, during inbound BiDi Record deserialization.","commonSituations":"Schema/browser version skew where one side treats a field as singular and the other as a list, grid rewriting arrays, spec evolution changing cardinality.","solutions":["Log the raw payload to see whether an array or scalar arrived at the failing field.","Confirm the field's list/scalar cardinality in the W3C BiDi spec for your browser version.","Align Selenium client and browser versions.","Report the divergence with the payload."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Confirm the cardinality your code expects matches the inbound container.\ndef expect_list!(value, field)\n  raise \"#{field} expected a list\" unless value.is_a?(::Array)\n  value\nend","typeGuard":"def bidi_list?(value)\n  value.is_a?(::Array)\nend","tryCatchPattern":"begin\n  record = SomeRecord.from_json(payload)\nrescue Selenium::WebDriver::Error::SerializationError => e\n  raise unless e.message =~ /expected.*list|expected a single value/\n  warn \"cardinality mismatch: #{e.message}\"\nend","preventionTips":["Log the raw value to confirm array-vs-scalar shape at the failing field.","Track spec cardinality changes for BiDi fields across versions.","Pin Selenium and browser versions together to avoid shape drift."],"tags":["bidi","serialization","list","schema","ruby"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}