{"record":{"id":"d8aa9e91b406e8cb","repo":"SeleniumHQ/selenium","slug":"name-expected-an-object-on-the-wire-got-json","errorCode":null,"errorMessage":"#{name} expected an object on the wire, got #{json_payload.inspect}","messagePattern":"#(.+?) expected an object on the wire, got #(.+?)","errorType":"exception","errorClass":"Error::SerializationError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/bidi/serialization/record.rb","lineNumber":88,"sourceCode":"          # @api private\n          module Deserializer\n            def new(**kwargs)\n              # Start from what was passed so ::Data's constructor rejects an unknown key, then fill\n              # each field with its value or UNSET (omitted), forcing fixed discriminators.\n              attributes = kwargs.dup\n              fields.each { |f| attributes[f.name] = fixed?(f) ? f.fixed : attributes.fetch(f.name, UNSET) }\n              attributes[:extensions] = kwargs.fetch(:extensions, {}) if extensible?\n              validate_values(attributes)\n              construct(**attributes)\n            end\n\n            # Inbound: builds from the wire. A missing required field is omitted and warned (or\n            # raised in strict mode, in +wire_value+); enum tokens are mapped back to symbols and an\n            # unrecognized one raises (in +read+); an undeclared property is captured silently\n            # (extensible) or warned and dropped (closed) — strict on shape, lenient on extras.\n            def from_json(json_payload)\n              unless json_payload.is_a?(::Hash)\n                raise Error::SerializationError, \"#{name} expected an object on the wire, got #{json_payload.inspect}\"\n              end\n\n              attributes = fields.to_h do |f|\n                [f.name, wire_value(f, json_payload)]\n              end\n              undeclared = extra(json_payload)\n              if extensible?\n                attributes[:extensions] = undeclared # the spec sanctions these extras; preserve them silently\n              else\n                warn_undeclared(undeclared) unless undeclared.empty?\n              end\n              construct(**attributes)\n            end\n\n            private\n\n            # Checks each field's value: a required field cannot be omitted (UNSET), a non-nullable\n            # field cannot be nil (nil is neither a value nor the UNSET omit-sentinel, so it would be","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/bidi/serialization/record.rb#L70-L106","documentation":"A BiDi serialization Record (a generated protocol type) expects the wire payload to be a JSON object (Ruby Hash). from_json raises Error::SerializationError when the inbound value is not a Hash (e.g. a bare string, number, or array arrived where an object was expected). It is a strict shape check on the response envelope.","triggerScenarios":"The browser/grid returns a non-object value at a field typed as a Record: a bare string where a struct is expected, an array, or a primitive. Reached during inbound deserialization of any BiDi response that mismatches the schema's object shape.","commonSituations":"Browser BiDi implementation diverges from the schema Selenium generated against; a proxy/grid rewrites the response; version skew between Selenium and browser; a malformed server response.","solutions":["Inspect the full BiDi response to see what non-object value arrived at the failing field.","Update Selenium to a version whose generated schema matches your browser.","Update/downgrade the browser to match the Selenium BiDi schema.","Report the schema mismatch with the offending payload to the Selenium project."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"def expect_bidi_object!(payload)\n  raise \"expected BiDi object, got #{payload.class}\" unless payload.is_a?(::Hash)\nend","typeGuard":"def bidi_object?(payload)\n  payload.is_a?(::Hash)\nend","tryCatchPattern":"begin\n  record = SomeRecord.from_json(payload)\nrescue Selenium::WebDriver::Error::SerializationError => e\n  warn \"BiDi shape error: #{e.message}\"\n  raise\nend","preventionTips":["Log the raw BiDi payload alongside the deserialization to diagnose shape mismatches.","Keep Selenium and browser/driver versions aligned.","Treat SerializationError as a schema-skew signal and file/report it with the payload."],"tags":["bidi","serialization","schema","ruby"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}