[Bug]: [py] Generated bidi.UserAgentClientHints is empty — inline CDDL params drop the command

オープン
#18,312 コメント 0 件 リアクション 0 件 担当者 2 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@titusfortner がすでに取り組んでいます。

2026年11月13日 から。

評価

この issue はまだ評価されていません。

説明

C-py OS-mac
Description
What I was trying to do

Call the WebDriver BiDi userAgentClientHints.setClientHintsOverride command from Python's public API, i.e. selenium.webdriver.common.bidi.UserAgentClientHints.

What I expected

The generated facade class to expose set_client_hints_override, the way the other generated BiDi modules expose their commands.

What actually happens

The class is generated with no methods at all — just __init__ and pass. It is the only one of the 21 generated facade modules in that state.

The command itself is not missing from the project: the internal selenium.webdriver.common._bidi.UserAgentClientHints.set_client_hints_override works, because that layer is generated from common/bidi/schema.json, which the JS pipeline normalises first (normalize_bidi_ast.mjs hoists the inline block into a synthetic userAgentClientHints.SetClientHintsOverrideCommandParams). Ruby's protocol layer has it for the same reason. Only the Python facade, which parses the CDDL directly, loses it.

Root cause

py/generate_bidi.py extracts commands with a pattern that only accepts a named params type:

method:\s*['\"]([^'\"]+)['\"],\s*params:\s*(\w+(?:\.\w+)*)

The pinned ua-client-hints grammar declares its params inline instead:

userAgentClientHints.SetClientHintsOverrideCommand = {
    method: "userAgentClientHints.setClientHintsOverride",
    params: {
        clientHints: userAgentClientHints.ClientHintsMetadata / null,
        ? contexts: [+text],
        ? userContexts: [+text],
    }
}

So the command matches nothing and is dropped with no diagnostic. _extract_types also skips the definition, because it contains method:, so the params record is never emitted either. Scanning the merged spec, this is the only command written that way — the other 110 all use named params, which is why nothing else is affected and why this went unnoticed.

It has been this way since #17378 (2026-04-27) added the extra CDDL specs. No test covers the public module, and the generator has no guard for a module that ends up with types but zero commands and zero events.

What I'd like to know before sending a patch

docs/decisions/17670-bidi-implementation-boundaries.md (Accepted) says the bidi modules are internal/unsupported and the supported API should be protocol-neutral, and #17814 tracks marking Python's bidi modules as internal. That makes the right fix a judgement call rather than an obvious one, so I'd rather ask than guess:

  1. Tooling fix only — hoist inline params into a named type so the generator stops dropping spec content, warn when a module would be emitted empty, and leave the facade class empty on purpose. Fixes the silent drop, changes nothing a user can call. I have this working with unit tests.
  2. Also expose the method — add a hand-shaped set_client_hints_override to the manifest, like emulation.set_geolocation_override. This genuinely closes the gap, but it adds a method to a surface ADR 17670 is retiring. Two traps make the plain generated template unusable here: it strips None, so it could never send the explicit clientHints: null that clears an override, and the generated dataclasses use snake_case fields with no camelCase serialiser. I have this working too, with a browser test passing on Chrome.
  3. Neither — if the public bidi facade is on its way out, the empty class is arguably correct and this should just be documented.

Happy to open a PR for whichever you prefer. No other binding has a supported API for this either (Java/.NET none, Ruby protocol-only and @api private), so if the answer is 2, it is probably worth a cross-binding discussion first.

Reproducible Code
# Generate the Python BiDi facade from the pinned CDDL specs
bazel build //py:create-bidi-src

# The generated public module has no commands -- it ends with:
#
#   class UserAgentClientHints:
#       """BiDi interface for overriding User-Agent Client Hints."""
#
#       def __init__(self, conn) -> None:
#           self._conn = conn
#
#       pass

# It is the only one of the 21 generated facade modules in that state:
grep -l '^    pass$' bazel-bin/py/selenium/webdriver/common/bidi/*.py
# -> bazel-bin/py/selenium/webdriver/common/bidi/user_agent_client_hints.py

# Public facade: __init__ only. Internal layer: has the command.
grep '    def ' py/selenium/webdriver/common/bidi/user_agent_client_hints.py
# ->     def __init__(self, conn) -> None:

grep '    def ' py/selenium/webdriver/common/_bidi/user_agent_client_hints.py
# ->     def set_client_hints_override(

# The single inline-params command in the merged spec, vs 110 named ones:
grep -c 'method:' bazel-bin/py/merged_bidi.cddl
python - <<'PY'
import re, pathlib
c = pathlib.Path("bazel-bin/py/merged_bidi.cddl").read_text()
inline = re.findall(r'method:\s*"([^"]+)",\s*params:\s*\{', c)
named  = re.findall(r'method:\s*"([^"]+)",\s*params:\s*(\w+(?:\.\w+)*)', c)
print("inline params:", inline)      # ['userAgentClientHints.setClientHintsOverride']
print("named params :", len(named))  # 110
PY
主要言語
Java
スター
34.6k
フォーク
8.7k
平均マージ
1日 23時間
マージ済み PR(30日)
86

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

SeleniumHQ/selenium のほかの issue

SeleniumHQ/selenium の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。