{"record":{"id":"45fb08e1cbdc7fc4","repo":"SeleniumHQ/selenium","slug":"name-received-a-variant-not-in-this-selenium-s","errorCode":null,"errorMessage":"#{name} received a variant not in this Selenium's BiDi schema: #{json_payload.inspect}","messagePattern":"#(.+?) received a variant not in this Selenium's BiDi schema: #(.+?)","errorType":"exception","errorClass":"Error::SerializationError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/bidi/serialization/union.rb","lineNumber":68,"sourceCode":"\n            # Declared (via the schema's `scalarValues` signal) on a non-object_only union whose\n            # bare-scalar arms are a fixed set of literals (input.Origin's \"viewport\" / \"pointer\").\n            # An outbound scalar outside that set matches no arm, so it is a caller error.\n            def scalar_values(*values) = @scalar_values = values\n\n            # A non-Hash payload is a bare scalar arm (e.g. input.Origin's \"viewport\") with no\n            # object to dispatch on, so it is returned unchanged — unless every arm is an object\n            # (object_only), where a non-Hash cannot match any variant and is a wire error.\n            def from_json(json_payload)\n              unless json_payload.is_a?(::Hash)\n                return json_payload unless @object_only\n\n                raise Error::SerializationError, \"#{name} expected an object on the wire, got #{json_payload.inspect}\"\n              end\n\n              variant = select(json_payload)\n              unless variant\n                raise Error::SerializationError,\n                      \"#{name} received a variant not in this Selenium's BiDi schema: #{json_payload.inspect}\"\n              end\n              Protocol.const_get(variant).from_json(json_payload)\n            end\n\n            # Outbound mirror of from_json: build the variant the command's kwargs describe\n            # so its typed as_json drives null-vs-absent per field (a flat hash through\n            # Transport cannot). Dispatch keys are wire names equal to their ruby kwarg\n            # (asserted at generation), so they match the kwargs by symbol. A mismatch here\n            # is a caller error (unlike an unknown inbound value), so it fails loudly.\n            def build(**kwargs)\n              variant = outbound_variant(kwargs) ||\n                        raise(::ArgumentError, \"no #{name} variant matches #{kwargs.inspect}\")\n              klass = Protocol.const_get(variant)\n              # An omitted optional arrives as UNSET; forward only what was provided. A provided\n              # key that isn't a field of the chosen variant is an invalid combination for this union.\n              provided = kwargs.reject { |_, value| UNSET.equal?(value) }\n              invalid = provided.keys - klass.fields.map(&:name)","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/bidi/serialization/union.rb#L50-L86","documentation":"For a BiDi Union, select() picks a variant by inspecting the payload's discriminator keys. If no declared variant matches the keys present, the union cannot deserialize the response and raises Error::SerializationError noting the variant is not in this Selenium's BiDi schema. This is forward-compat friction: the browser sent something newer than this Selenium knows.","triggerScenarios":"Browser emits a BiDi object whose discriminator does not match any variant arm in the Selenium schema. Reached on any inbound union deserialization (e.g. log entry types, browsingContext event types).","commonSituations":"Browser newer than Selenium adding a new variant, Selenium schema out of date, grid forwarding unsupported event types, custom browser BiDi extension.","solutions":["Upgrade Selenium to a version whose schema includes the new variant.","If you cannot upgrade, filter/avoid the BiDi event subscription that surfaces the unknown variant.","Report the unknown variant payload so the schema can be extended.","Downgrade the browser to match the Selenium schema if upgrading the client is blocked."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# You cannot enumerate variants without the schema; the practical guard is version alignment.\n# Subscribe only to event types you know your Selenium supports.\nSUPPORTED_EVENTS = %w[log entryAdded browsingContext].freeze\n","typeGuard":null,"tryCatchPattern":"begin\n  value = SomeUnion.from_json(payload)\nrescue Selenium::WebDriver::Error::SerializationError => e\n  raise unless e.message =~ /variant not in this Selenium's BiDi schema/\n  warn \"unknown BiDi variant (upgrade Selenium?): #{e.message}\"\nend","preventionTips":["Upgrade Selenium when adopting a newer browser that emits new BiDi variants.","Subscribe only to BiDi events your Selenium schema knows about.","Capture and report unknown-variant payloads upstream.","Maintain a pinned, tested Selenium+browser version matrix."],"tags":["bidi","serialization","union","schema","forward-compat","ruby"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}