[rb] validate nullable-constant BiDi params outbound - #17818
Conversation
|
Thank you, @titusfortner for this code suggestion. The support packages contain example code that many users find helpful, but they do not necessarily represent After reviewing the change, unless it is a critical fix or a feature that is needed for Selenium We actively encourage people to add the wrapper and helper code that makes sense for them to their own frameworks. |
PR Summary by QodoValidate nullable const-literals for Ruby BiDi outbound params
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
There was a problem hiding this comment.
Pull request overview
This PR tightens the Ruby BiDi serialization layer to locally validate nullable-const outbound parameters (literal-or-null) so off-spec values are rejected with an ArgumentError before any wire round-trip, aligning Ruby with the outbound-validation behavioral contract referenced in #17786.
Changes:
- Thread
{ const, nullable }schema information through the Ruby BiDi generator into runtimeRecord.definespecs (const:metadata). - Add runtime validation in
Serialization::Recordto enforceconstmembership for non-nil outbound values. - Add a unit regression spec covering the two affected nullable-const command params.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| rb/spec/unit/selenium/webdriver/bidi/serialization_spec.rb | Adds regression coverage ensuring invalid literal-or-null values raise locally. |
| rb/sig/lib/selenium/webdriver/bidi/serialization.rbs | Updates RBS signatures to include the new validate_const helper. |
| rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb | Extends generator IR to carry and emit const: metadata for runtime validation. |
| rb/lib/selenium/webdriver/bidi/serialization/record.rb | Implements outbound const validation in Record construction. |
| rb/lib/selenium/webdriver/bidi/protocol/emulation.rb | Regenerates protocol to include const: false for enabled on SetScriptingEnabledParameters. |
| rb/lib/selenium/webdriver/bidi/protocol/browsing_context.rb | Regenerates protocol to include const: true for bypass on SetBypassCSPParameters. |
| rb/.rubocop.yml | Adjusts RuboCop exclusions for the updated record.rb. |
🔗 Related Issues
Closes item 3 (outbound local validation) of the low-level WebDriver BiDi behavioral contract proposed in #17786. Schema signal it relies on was added in #17700.
💥 What does this PR do?
emulation.setScriptingEnabled'senabledandbrowsingContext.setBypassCSP'sbypass— with a localArgumentError, instead of serializing an off-spec value onto the wire for the remote end to reject on a round-trip.nullstill serialize exactly as before.🔧 Implementation Notes
{const, nullable}descriptor for these fields (since [js] Add binding-neutral BiDi schema with cddl2ts-gated fidelity #17700); the Ruby generator was consuming it only to type the RBS and dropping it from the runtime spec. This threads it through: the generator emitsconst:and the runtimeRecordvalidates it — no schema change needed.enabled's const isfalse(the spec lets you disable scripting or clear the override, not force it on), so the check handles a falsy literal via sentinels rather than truthiness.🤖 AI assistance
record.rb, the generator threading inbidi_generate.rb, the regenerated protocol files, and the test🔄 Types of changes