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

Abierto
#18,312 0 comentarios 0 reacciones 2 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@titusfortner ya está trabajando en esto.

Desde el 13/11/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

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
Lenguaje dominante
Java
Estrellas
34.6k
Forks
8.7k
Merge medio
1 d 23 h
PR fusionados (30 d)
86

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de SeleniumHQ/selenium

Todos los issues de SeleniumHQ/selenium

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.