Skip to content

[rust][java] Record sessions into Playwright-format traces via Selenium Manager - #18342

Open
bonigarcia wants to merge 46 commits into
SeleniumHQ:trunkfrom
bonigarcia:feature/trace-recording
Open

bonigarcia wants to merge 46 commits into
SeleniumHQ:trunkfrom
bonigarcia:feature/trace-recording

Conversation

@bonigarcia

@bonigarcia bonigarcia commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

🔗 Related Issues

Reference implementation for the ADR proposed in #18341. Please discuss the design there; this PR is for reviewing the code.

💥 What does this PR do?

Adds trace recording. With one option the session is saved as a Playwright trace archive (trace.zip), which opens in the Playwright trace viewer, the Vibium record player and the WebdriverIO trace viewer.

ChromeOptions options = new ChromeOptions();
options.setRecord("trace.zip");
WebDriver driver = new ChromeDriver(options);              // local driver
// or: new RemoteWebDriver(gridUrl, options);              // Selenium Grid or a cloud provider
// ...
driver.quit(); // trace.zip is written here

Selenium Manager (Rust)

  • Pipe mode: --pipe, implied by --record <path>. Selenium Manager runs a local HTTP proxy (127.0.0.1) and prints {"proxy_url": ...}. In front of a local driver it starts the driver the binding resolved (--driver-path); in front of a remote end it forwards to it (--upstream <url>) and manages no driver or browser.
  • BiDi is shared with the binding: the proxy owns the session's BiDi connection and, if the binding asked for BiDi, serves its own WebSocket endpoint and multiplexes the binding over it (rewritten command ids, events filtered by the binding's subscriptions, including the legacy unsubscribe by event names that the Java binding uses). The trace gets console and network data whether or not the binding uses BiDi.
  • Records every non-GET classic command and every non-query BiDi command of the binding, with its result or error, plus a screenshot after visual actions.
  • The trace is written before answering DELETE /session, so it is complete even when the binding stops the process straight away (on Windows, the process is killed, not signalled).
  • Redaction: typed passwords (including Actions chains that focus the field), authorization and cookie headers, cookie values, secret-like capability values and URL user info. Checks thatcannot be made count as sensitive.
  • If the BiDi connection is lost, the binding's connection is closed, a warning is logged and recording continues with classic WebDriver. A trace that cannot be written is reported as a {"trace_error": ...} line.

Java

  • AbstractDriverOptions#setRecord(String) / #getRecordPath() (@Beta).
  • TraceRecordingCommandExecutor (new, @Beta), with start (local driver) and startRemote. ChromeDriver, EdgeDriver, FirefoxDriver and the RemoteWebDriver constructors use it when recording is enabled; nothing changes otherwise.
  • Remote credentials (URL user info or ClientConfig credentials) reach Selenium Manager through SE_UPSTREAM_AUTHORIZATION, never its arguments; a ClientConfig proxy becomes --proxy.
  • SeleniumManager#startPipe(List<String>) and #startPipe(List<String>, Map<String, String>) (new, @Beta); ChromiumDriverCommandExecutor#withChromiumCommands (new, @Beta).

🔧 Implementation Notes

  • The format is Playwright trace schema v8.
  • The proxy is a small HTTP/1.1 server built on tokio; the binding's WebSocket handshake is done on the same listener. tokio-tungstenite is the only new crate family.
  • Driver resolution does not change: Java runs DriverFinder as usual and passes the result with--driver-path.
  • Bazel: bidi/log and bidi/module are now visible to the Chrome and Firefox test packages.

Tests

  • Rust unit tests: HTTP parsing, routing, capability injection and webSocketUrl rewriting, theWebSocket endpoint, id rewriting and event filtering over a fake BiDi endpoint, legacyunsubscribe, loss of the upstream connection, redaction, --upstream (credentials, proxy) andthe trace archive layout.
  • ChromeRecordingTest and FirefoxRecordingTest: recording without BiDi in the binding, andwith the binding using BiDi (LogInspector) at the same time.
  • RemoteRecordingTest: RemoteWebDriver against a Selenium Grid standalone, and a session thatcannot be created.
  • TraceRecordingCommandExecutorTest: ready line, trace errors, credentials and proxy arguments.

How to run the tests and get the traces locally:

bazel test --manager=host --headless \
  --test_env=SELENIUM_TRACE_DIR=$PWD/.local/traces \
  //java/test/org/openqa/selenium/chrome:recording-tests \
  //java/test/org/openqa/selenium/firefox:recording-tests \
  //java/test/org/openqa/selenium/grid/router:recording-tests
# then drop any .local/traces/*.zip on https://trace.playwright.dev, https://player.vibium.dev
# or https://trace.webdriver.io

🤖 AI assistance

  • No substantial AI assistance used
  • AI assisted (complete below)
    • Tool(s): OpenCode (first prototype), Claude Code (rework)
    • What was generated: most of the Rust and Java code, the tests, and the ADR draft
    • I reviewed all AI output and can explain the change

💡 Additional Considerations

  • Known limitations: wss:// BiDi endpoints need TLS in Selenium Manager's WebSocket client (a dependency change, left out of this PR); those sessions are recorded with classic WebDriver.
  • Follow-ups: Python, Ruby, .NET and JavaScript bindings; RemoteWebDriver.builder(); DOM snapshots and video.
  • In pipe mode only the driver executable is taken from the driver service; its port, arguments and log settings are not used.

🔄 Types of changes

  • New feature (non-breaking change which adds functionality and tests!)

🤖 Generated with Claude Code. Manually reviewed.

…va binding

- Fix POST body keep-alive bug (Connection: close, proper headers)
- Fix recording lifecycle (signal handlers → archiver::package on shutdown)
- Fix ZIP format (use ZipWriter from zip crate, remove manual ZIP)
- Fix NPE in pipe executor (extend HttpCommandExecutor directly)
- NDJSON trace format compatible with Playwright/Vibium viewers
- Per-action screenshots -> PNG resources + screencast-frame events
- Notification-specific action classification (page.*, element.*)
- Java binding: setRecord() in Chrome/Firefox/Edge via AbstractDriverOptions
- Java E2E test: 22 actions on bonigarcia.dev, traces to SELENIUM_TRACE_DIR
- Add ConsoleLog struct to recorder
- After each action, POST /session/{id}/log to capture console messages
- Emit console events in trace.trace (type: console)
- Java E2E test: navigate to console-logs.html
…um Manager

Selenium Manager gets a pipe mode (--pipe, implied by --record <path>) that
starts the driver behind a local HTTP proxy and records the session into a
Playwright trace archive (schema v8, readable by the Playwright trace viewer
and the Vibium record player).

- Records non-GET commands with results/errors, a screenshot after visual
  actions, console messages and network responses.
- Uses WebDriver BiDi when the binding does not use it itself (the proxy
  requests webSocketUrl and hides it from the binding); falls back to
  classic WebDriver otherwise.
- Writes the trace before answering DELETE /session, so bindings can stop
  the process right after quitting (also on Windows).
- Redacts text typed into password fields.
- --driver-path lets bindings pass the driver they already resolved.

Java: AbstractDriverOptions#setRecord (Beta) makes ChromeDriver, EdgeDriver
and FirefoxDriver use TraceRecordingCommandExecutor, which starts Selenium
Manager through the new SeleniumManager#startPipe.
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@selenium-ci

Copy link
Copy Markdown
Member

/agentic_describe

@selenium-ci selenium-ci added C-rust Rust code is mostly Selenium Manager B-manager Selenium Manager labels Nov 19, 2026
@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Record local WebDriver sessions as Playwright trace archives

✨ Enhancement 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Add opt-in trace recording for local Chrome, Edge, and Firefox sessions.
• Route commands through Selenium Manager to capture actions, screenshots, and available browser
 events.
• Save a Playwright-compatible archive on quit, with password-field text redacted.
Diagram

sequenceDiagram
    actor Caller as Java caller
    participant Executor as Recording executor
    participant Manager as Selenium Manager
    participant Proxy as Recording proxy
    participant Driver as Browser driver
    participant BiDi as BiDi endpoint
    participant Archive as Trace archive
    Caller->>Executor: Start recorded session
    Executor->>Manager: Start pipe with driver path
    Manager->>Proxy: Start local proxy
    Proxy->>Driver: Start and forward commands
    Proxy->>BiDi: Subscribe when available
    BiDi-->>Proxy: Console and network events
    Proxy->>Driver: Capture action screenshots
    Caller->>Executor: Quit session
    Executor->>Proxy: Delete session
    Proxy->>Archive: Write trace before reply
    Proxy-->>Executor: Quit response
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Record within each language binding
  • ➕ Avoids an additional local proxy and process handoff.
  • ➖ Duplicates recording logic across bindings.
  • ➖ Cannot capture browser events solely from classic HTTP command interception.
2. Use an established HTTP server framework for pipe mode
  • ➕ Provides mature HTTP parsing and connection handling.
  • ➖ Adds a framework dependency and potentially increases the Selenium Manager binary footprint.

Recommendation: The shared Selenium Manager proxy is the better cross-binding foundation and preserves existing driver resolution. Before broadening adoption, weigh the dependency savings of the hand-written HTTP server against its protocol and lifecycle maintenance cost.

Files changed (19) +3071 / -23

Enhancement (12) +2529 / -20
ChromeDriver.javaSelect recording execution for local Chrome sessions +13/-1

Select recording execution for local Chrome sessions

• Uses the trace recording executor when a record path is set, passing the resolved service executable and Chrome-specific commands. The existing executor remains the default.

java/src/org/openqa/selenium/chrome/ChromeDriver.java

EdgeDriver.javaSelect recording execution for local Edge sessions +13/-1

Select recording execution for local Edge sessions

• Routes opted-in Edge sessions through the recording executor with Edge-specific commands while retaining normal execution otherwise.

java/src/org/openqa/selenium/edge/EdgeDriver.java

FirefoxDriver.javaSelect recording execution for local Firefox sessions +13/-2

Select recording execution for local Firefox sessions

• Allows Firefox to use either the recording executor or its existing driver executor after normal driver resolution.

java/src/org/openqa/selenium/firefox/FirefoxDriver.java

SeleniumManager.javaStart and retain Selenium Manager in pipe mode +53/-14

Start and retain Selenium Manager in pipe mode

• Adds a beta process-starting API for pipe mode. Refactors SE_* property propagation so regular commands and pipe processes share it.

java/src/org/openqa/selenium/manager/SeleniumManager.java

AbstractDriverOptions.javaExpose an opt-in trace archive path +31/-0

Expose an opt-in trace archive path

• Adds beta record-path setter and getter to local driver options without sending the setting as a browser capability.

java/src/org/openqa/selenium/remote/AbstractDriverOptions.java

TraceRecordingCommandExecutor.javaManage the recording proxy from Java +202/-0

Manage the recording proxy from Java

• Starts Selenium Manager with the resolved driver and trace paths, discovers its proxy URL, and sends commands through it. Waits for pipe shutdown after quit and handles startup or early-close failures.

java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java

archiver.rsPackage recordings as Playwright schema-v8 traces +406/-0

Package recordings as Playwright schema-v8 traces

• Writes action and console NDJSON, network snapshots, and screenshot resources into a trace ZIP. Includes archive layout and timestamp tests.

rust/src/archiver.rs

bidi.rsCapture browser events through a BiDi client +221/-0

Capture browser events through a BiDi client

• Adds WebSocket command correlation, event dispatch, subscriptions, and screenshot capture for pipe mode. Tests those interactions against a fake endpoint.

rust/src/bidi.rs

lib.rsExport trace recording modules +4/-0

Export trace recording modules

• Exposes the archiver, BiDi client, pipe proxy, and recorder modules to Selenium Manager.

rust/src/lib.rs

main.rsAdd pipe and recording CLI modes +37/-2

Add pipe and recording CLI modes

• Adds --pipe, --record, and --driver-path options. Starts pipe mode after resolving a driver, or uses the supplied driver path.

rust/src/main.rs

pipe.rsProxy WebDriver sessions and coordinate recording +971/-0

Proxy WebDriver sessions and coordinate recording

• Starts a local driver and HTTP proxy, forwards commands, requests BiDi when available, and captures screenshots and logs. Saves the trace before replying to session deletion; tests parsing, routing, and a fake-driver session.

rust/src/pipe.rs

recorder.rsModel and classify recorded session activity +565/-0

Model and classify recorded session activity

• Stores actions, screenshots, console messages, and network responses with viewer-friendly action titles. Redacts text sent to password fields and tests classification and event conversion.

rust/src/recorder.rs

Tests (3) +425 / -0
ChromeRecordingTest.javaExercise recorded Chrome sessions +190/-0

Exercise recorded Chrome sessions

• Checks trace actions, packaged screenshots, password redaction, and BiDi console and network capture. Also tests recording when the binding itself requests BiDi.

java/test/org/openqa/selenium/chrome/ChromeRecordingTest.java

FirefoxRecordingTest.javaExercise recorded Firefox sessions +190/-0

Exercise recorded Firefox sessions

• Validates Firefox trace contents, screenshot resources, password redaction, and BiDi events. Covers the classic-command recording path when the binding requests BiDi.

java/test/org/openqa/selenium/firefox/FirefoxRecordingTest.java

TraceRecordingCommandExecutorTest.javaTest proxy URL discovery +45/-0

Test proxy URL discovery

• Verifies that the Java executor finds a ready JSON line among process logs and ignores invalid output.

java/test/org/openqa/selenium/remote/service/TraceRecordingCommandExecutorTest.java

Other (4) +117 / -3
BUILD.bazelAdd JSON dependency for Chrome recording tests +1/-0

Add JSON dependency for Chrome recording tests

• Makes the JSON library available to the Chrome test suite for trace inspection.

java/test/org/openqa/selenium/chrome/BUILD.bazel

BUILD.bazelRegister Firefox recording tests +2/-0

Register Firefox recording tests

• Adds the browser integration test to the large-test list and supplies its JSON dependency.

java/test/org/openqa/selenium/firefox/BUILD.bazel

Cargo.tomlEnable pipe-mode runtime and BiDi dependencies +5/-1

Enable pipe-mode runtime and BiDi dependencies

• Adds WebSocket, base64, futures, and signal-handling dependencies and enables the Tokio features needed by the proxy.

rust/Cargo.toml

Cargo.lockLock WebSocket dependency tree +109/-2

Lock WebSocket dependency tree

• Records tokio-tungstenite, tungstenite, and their additional transitive packages and versions.

rust/Cargo.lock

@qodo-code-review

qodo-code-review Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (14) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Remote credentials reach another host 🐞 Bug ⛨ Security ⭐ New
Description
on_session_created passes authorization headers intended for the configured upstream to
BiDiClient::connect without checking the returned webSocketUrl destination. When a remote end
returns a WebSocket URL on another host, recording sends those credentials in that host’s handshake
even if the binding did not request BiDi.
Code

rust/src/pipe.rs[R423-425]

+        let connected = match capabilities["webSocketUrl"].as_str().map(str::to_string) {
+            Some(url) if headers.is_empty() => {
+                self.connect_bidi(&url, &self.upstream_headers).await
Evidence
The pipe stores upstream authorization for the configured remote end, but uses the session
response’s WebSocket URL as a separate connection destination and inserts the same headers into its
handshake.

rust/src/pipe.rs[248-258]
rust/src/pipe.rs[420-429]
rust/src/bidi.rs[116-126]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Recording forwards upstream authorization to a WebSocket destination supplied by the session response, without checking whether that destination is trusted to receive it.
## Fix Focus Areas
- rust/src/pipe.rs[420-429]
- rust/src/bidi.rs[116-126]
## Recommended Fix
Validate the WebSocket destination against an explicit trusted origin or authorization policy before attaching upstream credentials. Do not send credentials to an untrusted WebSocket URL; add a test with a cross-origin URL.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


2. Invalid proxies send traffic directly 🐞 Bug ⛨ Security ⭐ New
Description
for_upstream selects an ordinary client when parsing the requested proxy fails, and also falls
back to one when building the configured client fails. With an invalid --proxy, forwarded
WebDriver requests can bypass the caller’s intended network route, including requests carrying
upstream authorization.
Code

rust/src/pipe.rs[R249-253]

+        let builder = match proxy.map(reqwest::Proxy::all) {
+            Some(Ok(proxy)) => Client::builder().proxy(proxy),
+            _ => Client::builder(),
+        };
+        self.client = builder.build().unwrap_or_else(|_| local_http_client());
Evidence
Only Some(Ok(proxy)) configures the reqwest client with a proxy; all other branches create a
default client. forward uses that client and adds upstream authorization when the incoming request
lacks it.

rust/src/pipe.rs[248-258]
rust/src/pipe.rs[368-392]
rust/src/main.rs[323-339]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
An invalid proxy or client-build error silently produces a client without the requested proxy.
## Fix Focus Areas
- rust/src/pipe.rs[248-253]
- rust/src/pipe.rs[141-151]
## Recommended Fix
Return proxy parsing and client construction errors from upstream setup and stop startup rather than substituting a default client. Test that an invalid proxy cannot result in an upstream request.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


3. Recording dismisses alerts the test expects 🐞 Bug ≡ Correctness ⭐ New
Description
After a recorded key-action chain runs, handle_connection calls password_field_focused(), which
sends a classic POST /execute/sync to the driver before the binding gets its response. The BiDi
input.performActions path at line 595 does the same. When the keys open a user prompt (for
example, pressing Enter submits a form that calls alert()), the driver's default `dismiss and
notify` prompt handling closes the prompt during this internal script. The test's next
switchTo().alert() then fails, so turning on recording changes how the test behaves.
Code

rust/src/pipe.rs[R332-334]

+        if types_keys && !hide_keys {
+            hide_keys = self.password_field_focused().await;
+        }
Evidence
The post-chain check runs on every recorded actions chain that contains key actions, in both the
classic and the BiDi path. It sends a classic execute-script request through the same session. Under
WebDriver's user-prompt handling, a script command with a prompt open applies the session's
unhandled-prompt behaviour, which defaults to dismissing the prompt. A failed check counts as
"password focused" (_ => true), so the keys are redacted and nothing visible shows that the alert
was closed.

rust/src/pipe.rs[300-334]
rust/src/pipe.rs[572-596]
rust/src/pipe.rs[617-640]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The password-focus check runs a classic `POST /execute/sync` before and after key action chains. If the chain opens an alert, the driver's default unhandled-prompt behaviour dismisses it during this internal call, which changes the test's outcome.

## Fix Focus Areas
- rust/src/pipe.rs[300-334]
- rust/src/pipe.rs[572-596]
- rust/src/pipe.rs[617-640]

## Recommended Fix
Before the post-chain check, send `GET /session/{id}/alert/text` (which does not trigger prompt handling). If a prompt is open, skip the script and redact the keys (fail closed). When a BiDi connection exists, run the check with `script.evaluate`/`script.callFunction` over BiDi instead, because BiDi does not apply classic prompt handling. Add a test where a key action triggers `alert()` and confirm the alert is still open afterwards.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


View high (2)
4. Chrome/Edge extras fail while recording ✓ Resolved

Resolving commit: a1c5dda

Resolution reason
Exposed ChromiumDriverCommandExecutor.withChromiumCommands as a public static helper and applied it
in ChromeDriver and EdgeDriver's recording path, so the Chromium-wide commands are included in the
map passed to TraceRecordingCommandExecutor.
Description
The recording path passes only ChromeDriverCommandExecutor.getExtraCommands() (casting + CDP) to
TraceRecordingCommandExecutor, skipping the network-conditions, permissions and launch-app
commands that ChromiumDriverCommandExecutor merges in. With setRecord(...) on, calls such as
setNetworkConditions, setPermission or launchApp fail because the executor has no command
definitions for them. The same problem affects EdgeDriver.

5. Quit succeeds even when no trace is saved ✓ Resolved

Resolving commit: a1c5dda

Resolution reason
Failed trace saves are now emitted as a {"trace_error": ...} JSON line on the pipe-mode stdout after
the session is quit; the Java binding parses it (findTraceError) and logs a warning to the user, so
the quit caller can learn the archive is missing without changing the DELETE response.
Description
finish_recording stores an archive-writing error in trace_result, but handle_connection still
returns the driver's successful DELETE response. If the destination is unwritable or packaging
fails, Java's quit() completes and the failure is only logged by Selenium Manager; the caller
receives no indication that the promised archive is missing.


Remediation recommended

6. Insecure mode cannot reach private Grid 🐞 Bug ≡ Correctness ⭐ New
Description
The upstream branch applies --insecure to selenium_manager but does not pass it into
PipeOptions or the pipe’s HTTP client. An HTTPS remote end with a certificate that requires this
flag still fails TLS validation for recorded WebDriver requests.
Code

rust/src/main.rs[R335-339]

+            .set_timeout(cli.timeout)
+            .and_then(|_| selenium_manager.set_proxy(cli.proxy.unwrap_or_default()))
+            .and_then(|_| selenium_manager.set_insecure(cli.insecure))
+            .and_then(|_| selenium_manager.stats())
+            .and_then(|_| pipe::run(options, selenium_manager.get_logger()));
Evidence
The CLI sets insecure on Selenium Manager, whereas the upstream path constructs an independent
default reqwest client. The existing client factory shows certificate validation must be configured
on the client actually making the request.

rust/src/main.rs[323-339]
rust/src/pipe.rs[92-101]
rust/src/pipe.rs[248-253]
rust/src/lib.rs[1883-1894]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Upstream pipe mode accepts `--insecure` but its requests use a separately constructed client that does not receive the setting.
## Fix Focus Areas
- rust/src/main.rs[323-339]
- rust/src/pipe.rs[92-101]
- rust/src/pipe.rs[248-253]
## Recommended Fix
Pass the insecure setting into `PipeOptions` and apply it when building the upstream HTTP client, consistently with Selenium Manager’s existing HTTP-client configuration. Test an HTTPS upstream with an untrusted certificate.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


7. Custom certificates stop remote recording 🐞 Bug ≡ Correctness ⭐ New
Description
startRemote moves upstream HTTPS requests into a Rust client without carrying over
ClientConfig.sslContext(). A remote session that works with the caller’s custom trust context can
fail certificate validation as soon as recording is enabled.
Code

java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[R162-169]

+    ExternalProcess pipe = SeleniumManager.getInstance().startPipe(arguments, environment);
+    try {
+      URL proxyUrl = awaitProxyUrl(pipe);
+      LOG.fine(String.format("Recording session to %s through %s", tracePath, proxyUrl));
+      // Selenium Manager runs on this machine: an HTTP proxy only applies beyond it.
+      ClientConfig local =
+          clientConfig.proxy() == null ? clientConfig : clientConfig.proxy(Proxy.NO_PROXY);
+      return new TraceRecordingCommandExecutor(additionalCommands, proxyUrl, local, pipe);
Evidence
The ordinary JDK client applies ClientConfig.sslContext(). The new remote-recording path sends
only the upstream URL, proxy, and authorization to Selenium Manager; its independently built reqwest
client has no equivalent trust configuration.

java/src/org/openqa/selenium/remote/http/jdk/JdkHttpClient.java[139-142]
java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[129-169]
rust/src/pipe.rs[248-253]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Remote recording replaces Java’s configured HTTPS client with a Rust client that does not receive its custom trust context.
## Fix Focus Areas
- java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[129-169]
- rust/src/pipe.rs[248-253]
## Recommended Fix
Provide a supported, secure way to apply the caller’s custom certificate trust to upstream requests, or reject this configuration explicitly before launching the recording proxy. Test a private-CA HTTPS remote end with `ClientConfig.sslContext()`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


8. A failed session start leaves processes running 🐞 Bug ☼ Reliability ⭐ New
Description
createExecutor starts a long-lived Selenium Manager pipe before a session exists, but
RemoteWebDriver constructor cleanup calls quit(), which returns immediately when sessionId is
null and never reaches closeExecutor() or stopPipe(). If NEW_SESSION fails because of bad
capabilities, a Grid refusal, or a browser crash, the pipe keeps polling, its recording remains
unfinalized, and in local mode the driver it started can also remain running.
Code

java/src/org/openqa/selenium/remote/RemoteWebDriver.java[R209-212]

+    if (recordPath != null) {
+      return TraceRecordingCommandExecutor.startRemote(
+          clientConfig.baseUrl(), capabilities, Path.of(recordPath), clientConfig);
+    }
Evidence
The executor starts a persistent child process before RemoteWebDriver attempts NEW_SESSION. On
constructor failure, cleanup calls quit(), but its null-session-ID return skips the
executor-closing path; TraceRecordingCommandExecutor.execute tracks QUIT without handling a
failed NEW_SESSION. The Rust pipe loop exits only when session_ended or a signal is set, and
ExternalProcess has no shutdown hook, so neither provides cleanup for this failure path.

java/src/org/openqa/selenium/remote/RemoteWebDriver.java[262-284]
java/src/org/openqa/selenium/remote/RemoteWebDriver.java[590-621]
java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[176-207]
rust/src/pipe.rs[161-171]
java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[156-169]
java/src/org/openqa/selenium/remote/RemoteWebDriver.java[275-286]
java/src/org/openqa/selenium/remote/RemoteWebDriver.java[590-617]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A failed `NEW_SESSION` leaves the recording executor open because constructor cleanup calls `quit()` before a session ID exists. The Selenium Manager pipe process, and the driver it started in local mode, can remain running.

## Fix Focus Areas
- java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[176-182]
- java/src/org/openqa/selenium/remote/RemoteWebDriver.java[203-215]
- java/src/org/openqa/selenium/remote/RemoteWebDriver.java[275-286]

## Recommended Fix
In `TraceRecordingCommandExecutor.execute`, wrap `super.execute` for `DriverCommand.NEW_SESSION`. If it throws or returns a response with no session ID or an error value, call `close()`/`stopPipe()` before propagating the failure, as `DriverCommandExecutor` does for its service. Ensure constructor failure closes an already-started recording executor even when no session ID was assigned. Add a failed-`NEW_SESSION` test in which the remote end rejects the session and verify that Selenium Manager exits.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


View medium (11)
9. Recording a proxied Grid loses BiDi data 🐞 Bug ≡ Correctness ⭐ New
Description
for_upstream applies --proxy to the reqwest HTTP client, but connect_bidi passes no proxy
configuration to BiDiClient::connect, which opens the upstream WebSocket directly with
connect_async. When the endpoint is reachable only through the proxy, session creation can succeed
while BiDi connection fails, forcing recording back to classic WebDriver without console or network
data and preventing bindings that requested BiDi from using the shared connection; when direct
access exists, BiDi traffic takes a different route.
Code

rust/src/pipe.rs[R249-253]

+        let builder = match proxy.map(reqwest::Proxy::all) {
+            Some(Ok(proxy)) => Client::builder().proxy(proxy),
+            _ => Client::builder(),
+        };
+        self.client = builder.build().unwrap_or_else(|_| local_http_client());
Evidence
The proxy setting reaches the reqwest HTTP client but is not passed through connect_bidi, which
calls BiDiClient::connect with only a URL, headers, and a handler. BiDiClient::connect builds
the request and calls connect_async directly, so the upstream WebSocket does not use the
configured proxy.

rust/src/pipe.rs[244-260]
rust/src/pipe.rs[444-470]
rust/src/bidi.rs[116-124]
rust/src/pipe.rs[141-151]
rust/src/pipe.rs[248-253]
rust/src/pipe.rs[450-455]
rust/src/bidi.rs[116-126]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
In `--upstream` mode, `--proxy` applies to HTTP WebDriver requests but not to the upstream BiDi WebSocket. An upstream whose WebSocket endpoint is reachable only through the proxy can accept session creation while BiDi connection and event recording fail.

## Fix Focus Areas
- rust/src/pipe.rs[244-260]
- rust/src/pipe.rs[420-470]
- rust/src/bidi.rs[116-130]

## Recommended Fix
Store the proxy URL in `ProxyState` and pass the upstream proxy configuration to `BiDiClient::connect`. When a proxy is set, open a TCP connection to it, send `CONNECT host:port` with `Proxy-Authorization` if the proxy URL has user info, wrap the tunnelled stream in TLS for `wss`, and establish the WebSocket with `tokio_tungstenite::client_async_tls` or `client_async`. Respect `NO_PROXY` and system proxy settings the same way reqwest does, and test recording against an upstream whose WebSocket endpoint is reachable only through the proxy.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


10. Header secrets in BiDi commands reach the trace 🐞 Bug ⛨ Security ⭐ New
Description
start_bidi_action records binding BiDi commands after redact_secrets, which masks only values
whose object key looks secret (key, secret, password, token) or a cookie object. Header
entries in network.continueRequest, network.provideResponse or network.continueResponse are
shaped {name: "Authorization", value: {type, value}}, and cookies arrays use the same shape, so
the bearer tokens and cookie values pass through untouched. A test that injects an auth header or
cookie through BiDi request interception writes it into trace.trace, even though network events in
the same archive already redact these headers.
Code

rust/src/recorder.rs[R143-146]

+    /// Registers a BiDi command sent by the binding; `None` when it is not recorded (queries).
+    pub fn start_bidi_action(&mut self, method: &str, params: &Value) -> Option<usize> {
+        let mut request_body = params.clone();
+        redact_secrets(&mut request_body);
Evidence
redact_secrets looks at object keys only. For a header entry the keys are name and value,
neither of which matches, so it recurses into {type, value}, where the key value also does not
match. Unclassified BiDi commands are still recorded through the _ => ActionInfo::new("BiDi", ...)
arm. is_sensitive_header is applied only in bidi_headers for network events.

rust/src/recorder.rs[143-159]
rust/src/recorder.rs[351-382]
rust/src/recorder.rs[398-447]
rust/src/recorder.rs[451-460]
rust/src/recorder.rs[518-535]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
BiDi network command parameters carry headers and cookies as `{name, value}` objects. `redact_secrets` matches only object keys, so Authorization/Cookie values and cookie values in `cookies` arrays are written to the trace.

## Fix Focus Areas
- rust/src/recorder.rs[398-447]
- rust/src/recorder.rs[451-460]

## Recommended Fix
In `redact_secrets`, when an object has a string `name` field and a `value` field: if `is_sensitive_header(name)` or `is_secret_name(name)` is true, replace the value (or its inner `value` for BiDi bytes values) with `REDACTED`. Also treat a `cookies` array key like `cookie`, calling `redact_cookie_value` on each element. Add unit tests for `network.continueRequest` with Authorization/Cookie headers and cookies.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


11. Local processes can use stored Grid credentials 🐞 Bug ⛨ Security ⭐ New
Description
In --upstream mode, for_upstream stores SE_UPSTREAM_AUTHORIZATION (or URL user info) in
upstream_headers, and forward adds it to every request that arrives without an Authorization
header. The proxy listens on an unauthenticated 127.0.0.1 port. While a recording runs, any other
local user or process can send WebDriver requests to that port (including POST /session) and have
them authenticated against the Grid or cloud account. Before this change, those requests would be
rejected by the remote end's basic auth.
Code

rust/src/pipe.rs[R254-258]

+        self.upstream_headers = authorization
+            .map(str::to_string)
+            .or_else(|| upstream_authorization(url))
+            .map(|value| vec![("Authorization".to_string(), value)])
+            .unwrap_or_default();
Evidence
The listener is bound on loopback and announced with no token or path secret. accept_loop serves
every connection, and forward adds upstream_headers whenever the incoming request has no
Authorization header. The Java side passes the credentials through the environment precisely to keep
them secret from other local users, but the proxy then lets those same users use them.

rust/src/pipe.rs[140-152]
rust/src/pipe.rs[187-201]
rust/src/pipe.rs[369-397]
java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[149-153]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The local recording proxy adds the upstream credentials to any request arriving on its loopback port without authentication, so other local processes can use the Grid credentials.

## Fix Focus Areas
- rust/src/pipe.rs[140-160]
- rust/src/pipe.rs[262-275]
- rust/src/pipe.rs[369-397]

## Recommended Fix
Generate a random token at startup and include it in the announced `proxy_url` as a path prefix (e.g. `http://127.0.0.1:port/<token>`). Reject, or forward without injected credentials, any request (including WebSocket upgrades) whose path lacks the prefix, and strip the prefix before forwarding. Java already uses the announced URL as the base, so no binding change is needed. Also reject requests whose Host header is not the loopback address, to block DNS rebinding.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


12. Session credentials enter trace archives ✓ Resolved

Resolving commit: a1c5dda

Resolution reason
Recorder's start_action now passes the request body through redact_secrets (which blanks
secret-named keys like accessKey/token/password and strips URL user info) before storing it in the
trace, while the forwarded request remains unchanged.
Description
start_action stores the full new-session request body, and before_event writes it into the
archive without filtering capability values. When capabilities contain credentials such as proxy
authentication or a vendor access key, recording copies those values into trace.trace even though
they are unrelated to the actions being reviewed.

13. Recording is silently dropped after merge 🐞 Bug ≡ Correctness
Description
setRecord stores the path in a plain Java field (recordPath) instead of a capability, and
ChromeOptions.merge, like the other options' merge, builds a new instance by copying
capabilities only. Code such as new ChromeDriver(options.merge(caps)) starts a normal session with
no recording and no warning, and the same applies to any path that copies options through
Capabilities.
Code

java/src/org/openqa/selenium/remote/AbstractDriverOptions.java[114]

+  private @Nullable String recordPath;
Evidence
merge creates new ChromeOptions() and calls mergeInPlace with capability maps, so the
non-capability recordPath field is lost. generateExecutor then reads options.getRecordPath(),
gets null and takes the regular path.

java/src/org/openqa/selenium/chrome/ChromeOptions.java[60-70]
java/src/org/openqa/selenium/remote/AbstractDriverOptions.java[114-142]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The trace path set via setRecord lives in a Java field that `merge()` does not copy, so merged options lose recording silently.

## Fix Focus Areas
- java/src/org/openqa/selenium/remote/AbstractDriverOptions.java[114-142]
- java/src/org/openqa/selenium/chrome/ChromeOptions.java[60-70]

## Recommended Fix
Store the path as a vendor capability (e.g. `se:record`) that the local drivers remove before the new-session request is sent. Alternatively, copy `recordPath` in each `merge` implementation (Chrome, Edge, Firefox) when the source is an AbstractDriverOptions. Add a test that `options.setRecord(x).merge(caps).getRecordPath()` returns x.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


14. A disconnected quit leaves the driver alive 🐞 Bug ☼ Reliability
Description
handle_connection sets session_ended only after writing and flushing the DELETE response, and
both operations can return early with an error. If the client disconnects after sending the quit
command, the trace may be written but the pipe keeps waiting and does not stop its driver process.
Code

rust/src/pipe.rs[R230-234]

+        write_response(stream, status, &content_type, &response_body).await?;
+        stream.flush().await?;
+
+        if route.is_delete_session() {
+            self.session_ended.store(true, Ordering::SeqCst);
Evidence
Fallible writes precede the termination flag, and the main loop and driver cleanup depend on that
flag.

rust/src/pipe.rs[224-235]
rust/src/pipe.rs[95-112]
rust/src/pipe.rs[687-706]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A failed DELETE response write prevents pipe shutdown after the driver session has ended.
## Fix Focus Areas
- rust/src/pipe.rs[224-235]
- rust/src/pipe.rs[95-112]
## Recommended Fix
Mark the session ended independently of successful socket writes once deletion has been processed, while preserving any write error for diagnostics. Test a client that disconnects immediately after sending DELETE.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


15. Standalone pipe startup rejects a driver ✓ Resolved

Resolving commit: a1c5dda

Resolution reason
Adds an early branch in main() before the manager selection chain: if cli.driver_path is set,
pipe-mode is requested, and no other selector is needed, the upstream/driver path is handled
directly. Specifically, the diff adds a new if let Some(upstream) = cli.upstream branch for
--upstream, and the existing driver-path pipe branch is reached via `.and_then(|driver_path| { if
pipe_mode {...} }). However the diff still routes --pipe --driver-path` through
selenium_manager.setup()-equivalent chain at the .and_then at line 365-ish unchanged, so the
standalone driver-path invocation itself is not explicitly fixed; the diff does not show the
driver-path selection branch at the flagged lines (329-332) being changed to skip the
browser/driver/grid selector.
Description
main selects a browser, driver, or grid manager before reaching the new driver_path branch that
skips driver resolution. Invoking the advertised standalone form `--pipe --driver-path
/path/to/driver` without also specifying a browser or driver exits with the existing
target-selection error.

16. Passwords typed via Actions reach the trace ✓ Resolved

Resolving commit: a1c5dda

Resolution reason
Keyboard Actions payloads are checked for a focused password field (before and after the command,
fail-closed on errors) and their key values are redacted in the recorded request body; BiDi
performActions gets the same treatment; secret-named fields and URL user info are redacted in
recorded bodies.
Description
Route::typed_element() matches only POST /element/{id}/value, so the password check and
redact_typed_text do not examine keyboard input sent through POST /actions. When a test enters a
password with new Actions(driver).sendKeys(field, secret), start_action retains the request body
and before_event writes it to params.body in the trace archive; secret-bearing executeScript
arguments can also be recorded there.

17. Recorded runs ignore custom driver flags 🐞 Bug ≡ Correctness
Description
TraceRecordingCommandExecutor.start passes only the executable path to Selenium Manager rather
than the service's configured arguments or environment. When a caller enables recording on a custom
driver service, flags and environment needed to start that driver are omitted, whereas the ordinary
service-start path uses them.
Code

java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[R98-105]

+    List<String> arguments =
+        List.of(
+            "--browser",
+            options.getBrowserName(),
+            "--driver-path",
+            driverPath,
+            "--record",
+            tracePath.toAbsolutePath().toString());
Evidence
The new path carries only browser, executable and archive path; normal DriverService startup applies
configured arguments and environment, while the pipe supplies only generated driver flags.

java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[75-106]
java/src/org/openqa/selenium/remote/service/DriverService.java[136-150]
rust/src/pipe.rs[724-742]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Enabling recording drops driver-service arguments and environment settings.
## Fix Focus Areas
- java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[75-106]
- rust/src/pipe.rs[724-742]
## Recommended Fix
Pass supported service startup arguments and environment into the pipe's driver launch, or explicitly reject unsupported custom services before starting a session. Test a service that requires a custom flag or environment variable.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


18. BiDi fallback stays hidden at debug level ✓ Resolved

Resolving commit: a1c5dda

Resolution reason
Added a severity-aware warning() queue on ProxyState that drain_diagnostics emits via log.warn.
connect_bidi failures now call self.warning("BiDi connection failed (...); recording with classic
WebDriver (no console or network data)"), the missing webSocketUrl case also warns, and losing the
upstream BiDi connection later warns. The binding-requested-webSocketUrl case was reworked so it no
longer silently falls back, and the diagnostics queue now carries a warning flag so the messages
reach default-level output.
Description
ProxyState::connect_bidi reports a failed BiDi connection only through diagnostic(), which
drain_diagnostics later emits with log.debug, so a default-level run gives no sign that console
and network events are being dropped. The same debug-only path covers the case where the binding
requests webSocketUrl itself and the proxy silently records classic WebDriver. Users then get a
trace without the console and network sections they expected, with nothing in the default output
explaining why.

19. Large uploads exhaust recording memory 🐞 Bug ➹ Performance
Description
start_action keeps each parsed non-GET request body in the in-memory recording until the session
ends, despite bounded limiting only its eventual archive representation. A session that sends
large file-upload payloads or repeated large scripts accumulates their full JSON bodies alongside
screenshots and can exhaust the Selenium Manager process.
Code

rust/src/recorder.rs[R99-105]

+    pub fn start_action(&mut self, http_method: &str, command_path: &str, body: &[u8]) -> usize {
+        let request_body = serde_json::from_slice::<Value>(body).ok();
+        let info = classify_command(http_method, command_path, request_body.as_ref());
+        self.actions.push(RecordedAction {
+            http_method: http_method.to_string(),
+            command_path: command_path.to_string(),
+            request_body,
Evidence
The recording retains a vector of actions containing parsed request bodies, while truncation occurs
only when events are emitted on shutdown. Selenium's file-upload command is a POST with a base64
file field.

rust/src/pipe.rs[186-191]
rust/src/recorder.rs[67-79]
rust/src/recorder.rs[98-113]
rust/src/archiver.rs[235-243]
java/src/org/openqa/selenium/remote/DriverCommand.java[343-345]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Recorded commands retain full large bodies for the lifetime of a session.
## Fix Focus Areas
- rust/src/recorder.rs[98-113]
- rust/src/archiver.rs[194-203]
- rust/src/archiver.rs[235-243]
## Recommended Fix
Apply size limits and sensitive-payload handling before storing command bodies, rather than only during archive serialization. Exercise repeated large requests and verify bounded memory use and useful trace metadata.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗



Informational

20. SOCKS proxy settings bypassed when recording 🐞 Bug ≡ Correctness ⭐ New
Description
proxyArgument returns null for SOCKS proxies and builds proxy URLs with unbracketed IPv6 literals,
while for_upstream silently falls back to a default client when it cannot parse a proxy URL. When
recording a remote session, launch also switches the Java binding to Proxy.NO_PROXY, so a
configured SOCKS proxy is lost and an IPv6 proxy URL can be ignored, leaving Grid traffic to use
default routing without warning.
Code

java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[R290-296]

+  static @Nullable String proxyArgument(ClientConfig clientConfig) {
+    Proxy proxy = clientConfig.proxy();
+    if (proxy == null || proxy.type() != Proxy.Type.HTTP) {
+      return null;
+    }
+    InetSocketAddress address = (InetSocketAddress) proxy.address();
+    return String.format("http://%s:%d", address.getHostString(), address.getPort());
Evidence
The ordinary Java client installs its configured proxy, including SOCKS, but the recording path
passes no proxy argument for SOCKS and removes the proxy from the local Java client. For IPv6 hosts,
getHostString() supplies an unbracketed literal in the constructed URL; the Rust upstream path
handles a failed reqwest::Proxy::all parse by building a client without that proxy.

java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[144-148]
java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[166-169]
rust/src/pipe.rs[248-253]
java/src/org/openqa/selenium/remote/http/jdk/JdkHttpClient.java[128-136]
java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[289-296]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The recording path loses a caller-configured SOCKS proxy when upstream requests move from Java to Selenium Manager. It also constructs invalid proxy URLs for IPv6 hosts, which the upstream client silently ignores.

## Fix Focus Areas
- java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[144-148]
- java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[289-297]
- rust/src/pipe.rs[248-253]

## Recommended Fix
Pass supported SOCKS settings through to the upstream client by mapping `Proxy.Type.SOCKS` to `socks5://host:port` with reqwest's `socks` feature, or reject or warn about unsupported proxy types before recording starts. Bracket IPv6 literals when constructing proxy URLs. In `for_upstream`, return an error or at least log a warning if `reqwest::Proxy::all` fails rather than silently building a direct client. Add a test covering a SOCKS-only remote endpoint.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


21. Trace stores cookies and auth headers ✓ Resolved

Resolving commit: a1c5dda

Resolution reason
bidi_headers now replaces values of Authorization, Proxy-Authorization, Cookie and Set-Cookie
headers with the REDACTED constant (via new is_sensitive_header helper) before they are stored in
the network entries, so cookies and auth tokens no longer reach trace.network or the archive. A unit
test (redacts_sensitive_headers) covers this.
Description
network_from_bidi copies every request and response header through bidi_headers without
filtering credential-bearing values, and har_headers serializes those values unchanged. When a
BiDi-recorded session makes authenticated requests, cookies and authorization tokens reach
trace.network and the shareable archive.

Grey Divider

Context sources
✅ Linked PRs:
  🌐 PR #18341
✅ Web pages:
  +2 more
✅ Context preparation
  Commit messages: summarized; full text retained for this review
Review mode: Auto: 🧠 Deep: Substantial new Rust and Java logic spans multiple independent recording paths.

Grey Divider

⚠️ Warning | Comment size exceeded, non finding content trimmed Learn more

Grey Divider

Qodo Logo

Comment thread rust/src/pipe.rs Resolved
Comment thread rust/src/pipe.rs Resolved
Comment thread rust/src/pipe.rs
Comment on lines +230 to +234
write_response(stream, status, &content_type, &response_body).await?;
stream.flush().await?;

if route.is_delete_session() {
self.session_ended.store(true, Ordering::SeqCst);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

4. A disconnected quit leaves the driver alive 🐞 Bug ☼ Reliability

handle_connection sets session_ended only after writing and flushing the DELETE response, and
both operations can return early with an error. If the client disconnects after sending the quit
command, the trace may be written but the pipe keeps waiting and does not stop its driver process.
Agent Prompt
## Issue description
A failed DELETE response write prevents pipe shutdown after the driver session has ended.
## Fix Focus Areas
- rust/src/pipe.rs[224-235]
- rust/src/pipe.rs[95-112]
## Recommended Fix
Mark the session ended independently of successful socket writes once deletion has been processed, while preserving any write error for diagnostics. Test a client that disconnects immediately after sending DELETE.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment thread rust/src/pipe.rs Resolved
Comment thread rust/src/recorder.rs
Comment on lines +99 to +105
pub fn start_action(&mut self, http_method: &str, command_path: &str, body: &[u8]) -> usize {
let request_body = serde_json::from_slice::<Value>(body).ok();
let info = classify_command(http_method, command_path, request_body.as_ref());
self.actions.push(RecordedAction {
http_method: http_method.to_string(),
command_path: command_path.to_string(),
request_body,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

6. Large uploads exhaust recording memory 🐞 Bug ➹ Performance

start_action keeps each parsed non-GET request body in the in-memory recording until the session
ends, despite bounded limiting only its eventual archive representation. A session that sends
large file-upload payloads or repeated large scripts accumulates their full JSON bodies alongside
screenshots and can exhaust the Selenium Manager process.
Agent Prompt
## Issue description
Recorded commands retain full large bodies for the lifetime of a session.
## Fix Focus Areas
- rust/src/recorder.rs[98-113]
- rust/src/archiver.rs[194-203]
- rust/src/archiver.rs[235-243]
## Recommended Fix
Apply size limits and sensitive-payload handling before storing command bodies, rather than only during archive serialization. Exercise repeated large requests and verify bounded memory use and useful trace metadata.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment thread rust/src/main.rs Resolved
return self();
}

private @Nullable String recordPath;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

9. Recording is silently dropped after merge 🐞 Bug ≡ Correctness

setRecord stores the path in a plain Java field (recordPath) instead of a capability, and
ChromeOptions.merge, like the other options' merge, builds a new instance by copying
capabilities only. Code such as new ChromeDriver(options.merge(caps)) starts a normal session with
no recording and no warning, and the same applies to any path that copies options through
Capabilities.
Agent Prompt
## Issue description
The trace path set via setRecord lives in a Java field that `merge()` does not copy, so merged options lose recording silently.

## Fix Focus Areas
- java/src/org/openqa/selenium/remote/AbstractDriverOptions.java[114-142]
- java/src/org/openqa/selenium/chrome/ChromeOptions.java[60-70]

## Recommended Fix
Store the path as a vendor capability (e.g. `se:record`) that the local drivers remove before the new-session request is sent. Alternatively, copy `recordPath` in each `merge` implementation (Chrome, Edge, Firefox) when the source is an AbstractDriverOptions. Add a test that `options.setRecord(x).merge(caps).getRecordPath()` returns x.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment thread rust/src/pipe.rs Resolved
Comment thread rust/src/recorder.rs Resolved
The recording tests drive Selenium Manager's pipe mode, so they fail where
the bundled manager is a stub (RBE, --manager=stub). Move them to their own
suites tagged se-manager, which get the manager built from source and
network access, and drop the -remote variants: recording only applies when
the binding starts the driver itself.
@bonigarcia bonigarcia changed the title [rust][java] Record sessions into Playwright-format traces via Selenium Manager [rust][java] Record sessions into Playwright-format traces via Selenium Manager Nov 19, 2026
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 6ebb42e

bonigarcia and others added 17 commits November 20, 2026 12:19
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…onnection

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ording

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cription id

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ection is lost

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, failing closed

Internal requests of the proxy carry the binding's credentials, focus is followed into
shadow roots and frames, and a check that cannot be made counts as a password field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ad of the command line

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…honor the client proxy

Credentials (URL user info or ClientConfig credentials) reach Selenium Manager through
SE_UPSTREAM_AUTHORIZATION, the client proxy becomes --proxy for the remote end, and the
local hop to Selenium Manager bypasses it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@selenium-ci

Copy link
Copy Markdown
Member

/agentic_review

Comment thread rust/src/pipe.rs
Comment on lines +423 to +425
let connected = match capabilities["webSocketUrl"].as_str().map(str::to_string) {
Some(url) if headers.is_empty() => {
self.connect_bidi(&url, &self.upstream_headers).await

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Remote credentials reach another host 🐞 Bug ⛨ Security

on_session_created passes authorization headers intended for the configured upstream to
BiDiClient::connect without checking the returned webSocketUrl destination. When a remote end
returns a WebSocket URL on another host, recording sends those credentials in that host’s handshake
even if the binding did not request BiDi.
Agent Prompt
## Issue description
Recording forwards upstream authorization to a WebSocket destination supplied by the session response, without checking whether that destination is trusted to receive it.
## Fix Focus Areas
- rust/src/pipe.rs[420-429]
- rust/src/bidi.rs[116-126]
## Recommended Fix
Validate the WebSocket destination against an explicit trusted origin or authorization policy before attaching upstream credentials. Do not send credentials to an untrusted WebSocket URL; add a test with a cross-origin URL.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment thread rust/src/pipe.rs
Comment on lines +249 to +253
let builder = match proxy.map(reqwest::Proxy::all) {
Some(Ok(proxy)) => Client::builder().proxy(proxy),
_ => Client::builder(),
};
self.client = builder.build().unwrap_or_else(|_| local_http_client());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. Invalid proxies send traffic directly 🐞 Bug ⛨ Security

for_upstream selects an ordinary client when parsing the requested proxy fails, and also falls
back to one when building the configured client fails. With an invalid --proxy, forwarded
WebDriver requests can bypass the caller’s intended network route, including requests carrying
upstream authorization.
Agent Prompt
## Issue description
An invalid proxy or client-build error silently produces a client without the requested proxy.
## Fix Focus Areas
- rust/src/pipe.rs[248-253]
- rust/src/pipe.rs[141-151]
## Recommended Fix
Return proxy parsing and client construction errors from upstream setup and stop startup rather than substituting a default client. Test that an invalid proxy cannot result in an upstream request.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment thread rust/src/main.rs
Comment on lines +335 to +339
.set_timeout(cli.timeout)
.and_then(|_| selenium_manager.set_proxy(cli.proxy.unwrap_or_default()))
.and_then(|_| selenium_manager.set_insecure(cli.insecure))
.and_then(|_| selenium_manager.stats())
.and_then(|_| pipe::run(options, selenium_manager.get_logger()));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

6. Insecure mode cannot reach private grid 🐞 Bug ≡ Correctness

The upstream branch applies --insecure to selenium_manager but does not pass it into
PipeOptions or the pipe’s HTTP client. An HTTPS remote end with a certificate that requires this
flag still fails TLS validation for recorded WebDriver requests.
Agent Prompt
## Issue description
Upstream pipe mode accepts `--insecure` but its requests use a separately constructed client that does not receive the setting.
## Fix Focus Areas
- rust/src/main.rs[323-339]
- rust/src/pipe.rs[92-101]
- rust/src/pipe.rs[248-253]
## Recommended Fix
Pass the insecure setting into `PipeOptions` and apply it when building the upstream HTTP client, consistently with Selenium Manager’s existing HTTP-client configuration. Test an HTTPS upstream with an untrusted certificate.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment on lines +162 to +169
ExternalProcess pipe = SeleniumManager.getInstance().startPipe(arguments, environment);
try {
URL proxyUrl = awaitProxyUrl(pipe);
LOG.fine(String.format("Recording session to %s through %s", tracePath, proxyUrl));
// Selenium Manager runs on this machine: an HTTP proxy only applies beyond it.
ClientConfig local =
clientConfig.proxy() == null ? clientConfig : clientConfig.proxy(Proxy.NO_PROXY);
return new TraceRecordingCommandExecutor(additionalCommands, proxyUrl, local, pipe);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

7. Custom certificates stop remote recording 🐞 Bug ≡ Correctness

startRemote moves upstream HTTPS requests into a Rust client without carrying over
ClientConfig.sslContext(). A remote session that works with the caller’s custom trust context can
fail certificate validation as soon as recording is enabled.
Agent Prompt
## Issue description
Remote recording replaces Java’s configured HTTPS client with a Rust client that does not receive its custom trust context.
## Fix Focus Areas
- java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[129-169]
- rust/src/pipe.rs[248-253]
## Recommended Fix
Provide a supported, secure way to apply the caller’s custom certificate trust to upstream requests, or reject this configuration explicitly before launching the recording proxy. Test a private-CA HTTPS remote end with `ClientConfig.sslContext()`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment thread rust/src/pipe.rs
Comment on lines +332 to +334
if types_keys && !hide_keys {
hide_keys = self.password_field_focused().await;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

3. Recording dismisses alerts the test expects 🐞 Bug ≡ Correctness

After a recorded key-action chain runs, handle_connection calls password_field_focused(), which
sends a classic POST /execute/sync to the driver before the binding gets its response. The BiDi
input.performActions path at line 595 does the same. When the keys open a user prompt (for
example, pressing Enter submits a form that calls alert()), the driver's default `dismiss and
notify` prompt handling closes the prompt during this internal script. The test's next
switchTo().alert() then fails, so turning on recording changes how the test behaves.
Agent Prompt
## Issue description
The password-focus check runs a classic `POST /execute/sync` before and after key action chains. If the chain opens an alert, the driver's default unhandled-prompt behaviour dismisses it during this internal call, which changes the test's outcome.

## Fix Focus Areas
- rust/src/pipe.rs[300-334]
- rust/src/pipe.rs[572-596]
- rust/src/pipe.rs[617-640]

## Recommended Fix
Before the post-chain check, send `GET /session/{id}/alert/text` (which does not trigger prompt handling). If a prompt is open, skip the script and redact the keys (fail closed). When a BiDi connection exists, run the check with `script.evaluate`/`script.callFunction` over BiDi instead, because BiDi does not apply classic prompt handling. Add a test where a key action triggers `alert()` and confirm the alert is still open afterwards.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment on lines +209 to +212
if (recordPath != null) {
return TraceRecordingCommandExecutor.startRemote(
clientConfig.baseUrl(), capabilities, Path.of(recordPath), clientConfig);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

8. A failed session start leaves processes running 🐞 Bug ☼ Reliability

createExecutor starts a long-lived Selenium Manager pipe before a session exists, but
RemoteWebDriver constructor cleanup calls quit(), which returns immediately when sessionId is
null and never reaches closeExecutor() or stopPipe(). If NEW_SESSION fails because of bad
capabilities, a Grid refusal, or a browser crash, the pipe keeps polling, its recording remains
unfinalized, and in local mode the driver it started can also remain running.
Agent Prompt
## Issue description
A failed `NEW_SESSION` leaves the recording executor open because constructor cleanup calls `quit()` before a session ID exists. The Selenium Manager pipe process, and the driver it started in local mode, can remain running.

## Fix Focus Areas
- java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[176-182]
- java/src/org/openqa/selenium/remote/RemoteWebDriver.java[203-215]
- java/src/org/openqa/selenium/remote/RemoteWebDriver.java[275-286]

## Recommended Fix
In `TraceRecordingCommandExecutor.execute`, wrap `super.execute` for `DriverCommand.NEW_SESSION`. If it throws or returns a response with no session ID or an error value, call `close()`/`stopPipe()` before propagating the failure, as `DriverCommandExecutor` does for its service. Ensure constructor failure closes an already-started recording executor even when no session ID was assigned. Add a failed-`NEW_SESSION` test in which the remote end rejects the session and verify that Selenium Manager exits.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment thread rust/src/pipe.rs
Comment on lines +249 to +253
let builder = match proxy.map(reqwest::Proxy::all) {
Some(Ok(proxy)) => Client::builder().proxy(proxy),
_ => Client::builder(),
};
self.client = builder.build().unwrap_or_else(|_| local_http_client());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

9. Recording a proxied grid loses bidi data 🐞 Bug ≡ Correctness

for_upstream applies --proxy to the reqwest HTTP client, but connect_bidi passes no proxy
configuration to BiDiClient::connect, which opens the upstream WebSocket directly with
connect_async. When the endpoint is reachable only through the proxy, session creation can succeed
while BiDi connection fails, forcing recording back to classic WebDriver without console or network
data and preventing bindings that requested BiDi from using the shared connection; when direct
access exists, BiDi traffic takes a different route.
Agent Prompt
## Issue description
In `--upstream` mode, `--proxy` applies to HTTP WebDriver requests but not to the upstream BiDi WebSocket. An upstream whose WebSocket endpoint is reachable only through the proxy can accept session creation while BiDi connection and event recording fail.

## Fix Focus Areas
- rust/src/pipe.rs[244-260]
- rust/src/pipe.rs[420-470]
- rust/src/bidi.rs[116-130]

## Recommended Fix
Store the proxy URL in `ProxyState` and pass the upstream proxy configuration to `BiDiClient::connect`. When a proxy is set, open a TCP connection to it, send `CONNECT host:port` with `Proxy-Authorization` if the proxy URL has user info, wrap the tunnelled stream in TLS for `wss`, and establish the WebSocket with `tokio_tungstenite::client_async_tls` or `client_async`. Respect `NO_PROXY` and system proxy settings the same way reqwest does, and test recording against an upstream whose WebSocket endpoint is reachable only through the proxy.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment thread rust/src/recorder.rs
Comment on lines +143 to +146
/// Registers a BiDi command sent by the binding; `None` when it is not recorded (queries).
pub fn start_bidi_action(&mut self, method: &str, params: &Value) -> Option<usize> {
let mut request_body = params.clone();
redact_secrets(&mut request_body);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

10. Header secrets in bidi commands reach the trace 🐞 Bug ⛨ Security

start_bidi_action records binding BiDi commands after redact_secrets, which masks only values
whose object key looks secret (key, secret, password, token) or a cookie object. Header
entries in network.continueRequest, network.provideResponse or network.continueResponse are
shaped {name: "Authorization", value: {type, value}}, and cookies arrays use the same shape, so
the bearer tokens and cookie values pass through untouched. A test that injects an auth header or
cookie through BiDi request interception writes it into trace.trace, even though network events in
the same archive already redact these headers.
Agent Prompt
## Issue description
BiDi network command parameters carry headers and cookies as `{name, value}` objects. `redact_secrets` matches only object keys, so Authorization/Cookie values and cookie values in `cookies` arrays are written to the trace.

## Fix Focus Areas
- rust/src/recorder.rs[398-447]
- rust/src/recorder.rs[451-460]

## Recommended Fix
In `redact_secrets`, when an object has a string `name` field and a `value` field: if `is_sensitive_header(name)` or `is_secret_name(name)` is true, replace the value (or its inner `value` for BiDi bytes values) with `REDACTED`. Also treat a `cookies` array key like `cookie`, calling `redact_cookie_value` on each element. Add unit tests for `network.continueRequest` with Authorization/Cookie headers and cookies.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment thread rust/src/pipe.rs
Comment on lines +254 to +258
self.upstream_headers = authorization
.map(str::to_string)
.or_else(|| upstream_authorization(url))
.map(|value| vec![("Authorization".to_string(), value)])
.unwrap_or_default();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

11. Local processes can use stored grid credentials 🐞 Bug ⛨ Security

In --upstream mode, for_upstream stores SE_UPSTREAM_AUTHORIZATION (or URL user info) in
upstream_headers, and forward adds it to every request that arrives without an Authorization
header. The proxy listens on an unauthenticated 127.0.0.1 port. While a recording runs, any other
local user or process can send WebDriver requests to that port (including POST /session) and have
them authenticated against the Grid or cloud account. Before this change, those requests would be
rejected by the remote end's basic auth.
Agent Prompt
## Issue description
The local recording proxy adds the upstream credentials to any request arriving on its loopback port without authentication, so other local processes can use the Grid credentials.

## Fix Focus Areas
- rust/src/pipe.rs[140-160]
- rust/src/pipe.rs[262-275]
- rust/src/pipe.rs[369-397]

## Recommended Fix
Generate a random token at startup and include it in the announced `proxy_url` as a path prefix (e.g. `http://127.0.0.1:port/<token>`). Reject, or forward without injected credentials, any request (including WebSocket upgrades) whose path lacks the prefix, and strip the prefix before forwarding. Java already uses the announced URL as the base, so no binding change is needed. Also reject requests whose Host header is not the loopback address, to block DNS rebinding.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment on lines +290 to +296
static @Nullable String proxyArgument(ClientConfig clientConfig) {
Proxy proxy = clientConfig.proxy();
if (proxy == null || proxy.type() != Proxy.Type.HTTP) {
return null;
}
InetSocketAddress address = (InetSocketAddress) proxy.address();
return String.format("http://%s:%d", address.getHostString(), address.getPort());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Informational

20. Socks proxy settings bypassed when recording 🐞 Bug ≡ Correctness

proxyArgument returns null for SOCKS proxies and builds proxy URLs with unbracketed IPv6 literals,
while for_upstream silently falls back to a default client when it cannot parse a proxy URL. When
recording a remote session, launch also switches the Java binding to Proxy.NO_PROXY, so a
configured SOCKS proxy is lost and an IPv6 proxy URL can be ignored, leaving Grid traffic to use
default routing without warning.
Agent Prompt
## Issue description
The recording path loses a caller-configured SOCKS proxy when upstream requests move from Java to Selenium Manager. It also constructs invalid proxy URLs for IPv6 hosts, which the upstream client silently ignores.

## Fix Focus Areas
- java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[144-148]
- java/src/org/openqa/selenium/remote/service/TraceRecordingCommandExecutor.java[289-297]
- rust/src/pipe.rs[248-253]

## Recommended Fix
Pass supported SOCKS settings through to the upstream client by mapping `Proxy.Type.SOCKS` to `socks5://host:port` with reqwest's `socks` feature, or reject or warn about unsupported proxy types before recording starts. Bracket IPv6 literals when constructing proxy URLs. In `for_upstream`, return an error or at least log a warning if `reqwest::Proxy::all` fails rather than silently building a direct client. Add a test covering a SOCKS-only remote endpoint.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit a1c5dda

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-build Includes scripting, bazel and CI integrations B-manager Selenium Manager C-java Java Bindings C-rust Rust code is mostly Selenium Manager

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants