You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The message received from browsers during a BiDi session was decoded 3 times or more for each incoming message. Fixing that to decode almost only once and use the decoded result to map to typed object.
🔧 Implementation Notes
Simplest way to do without interfering with other JSON flows.
🤖 AI assistance
No substantial AI assistance used
AI assisted (complete below)
Tool(s):
What was generated:
I reviewed all AI output and can explain the change
The public Command constructors now accept Function<@Nullable Object, X> instead of
Function<JsonInput, X>, and ConverterFunctions.map exposes the same incompatible generic change.
Existing clients that explicitly pass, return, or store Function<JsonInput, X> cannot recompile
because Java function types are invariant, even though the erased binary signature remains
unchanged.
Rule 1 requires public API compatibility. The changed constructor parameter and helper return type
replace Function<JsonInput, X> with invariant Function<Object, X>, which is a
source-incompatible public API change.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
Public command mapper signatures changed from `Function<JsonInput, X>` to `Function<Object, X>`, breaking recompilation of existing client code that explicitly uses the former type.
## Fix Focus Areas
- java/src/org/openqa/selenium/bidi/Command.java[55-64]
- java/src/org/openqa/selenium/bidi/ConverterFunctions.java[51-58]
## Recommended Fix
Preserve the existing `JsonInput`-based public signatures and introduce a distinctly named parsed-result factory or functional interface with a different erased type for the new internal path. Migrate Selenium's internal mappers to that new API while adapting legacy mappers so existing client source continues to compile.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Connection.handleResponse now dispatches an already-parsed nullable result or reconstructed error
without a focused unit test of either callback path. The added JsonTest cases exercise only
Json.convert, while successful response dispatch, error propagation, callback removal, and mapper
invocation remain dependent on broader integration coverage.
Rule 4 requires focused unit coverage for relevant changes where practical. The PR changes the
central BiDi response-dispatch representation and callback behavior, but its added tests cover only
the standalone JSON conversion method.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
The central BiDi response-dispatch contract changed, but the PR only adds tests for the lower-level conversion helper and does not directly verify the new callback behavior.
## Fix Focus Areas
- java/src/org/openqa/selenium/bidi/Connection.java[315-326]
- java/test/org/openqa/selenium/json/JsonTest.java[170-222]
## Recommended Fix
Add focused connection-level unit tests that feed representative successful and error responses into the handler and assert callback removal, parsed result delivery, mapper invocation, and exception propagation without requiring a browser.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
3. Browser responses are decoded twice 🐞 Bug➹ Performance
Description
Json.convert serializes its already-parsed source with toJson and immediately passes the
resulting text to toType, invoking the JSON parser again instead of coercing the object tree
directly. After Connection.handle has parsed each WebSocket message into a map, every type-based
Command and typed ConverterFunctions.map result reaches this helper, retaining a full
serialization and parse on the common BiDi response path.
Connection.handle first parses each incoming message into raw and passes the parsed result
object to command mappers, while the generic Command(Type) constructor and typed field converter
both invoke Json.convert. The implementation of convert then calls toJson followed by
toType, proving that these already-parsed values are serialized and parsed a second time.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
`Json.convert` currently turns an already-parsed value back into JSON text and parses it again, so typed BiDi command and result-field mapping still performs a second full JSON traversal.
## Fix Focus Areas
- java/src/org/openqa/selenium/json/Json.java[217-240]
- java/src/org/openqa/selenium/bidi/Command.java[47-52]
- java/src/org/openqa/selenium/bidi/ConverterFunctions.java[55-57]
## Recommended Fix
Implement a direct object-to-type coercion path in the JSON coercion layer that consumes parsed `Map`, `List`, scalar, and null values without producing intermediate JSON text. Make `Json.convert`, type-based commands, and typed converter functions use that path instead of `toType(toJson(source), typeOfT)`, preserve the existing null return contract, and add tests covering scalar, bean, and typed-list conversion while proving that conversion neither serializes nor parses the source.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
4. Deep browser responses fail to map 🐞 Bug≡ Correctness
Description
Json.convert round-trips an already-parsed map or list through the default toJson overload,
imposing JsonOutput.MAX_DEPTH of 100 instead of directly coercing the object tree as the prior
JsonInput mapping did. When script serialization requests more than 100 nested object levels,
evaluate, call-function, and other deeply nested typed command results throw during mapping and
complete exceptionally despite having been parsed successfully.
The new conversion path explicitly accepts parsed map and list structures but calls toJson(source)
before toType; toJson(Object) uses JsonOutput.MAX_DEPTH, defined as 100 and enforced while
traversing nested collections and maps. BiDi callers can request object serialization deeper than
that threshold, so the output-depth exception occurs during typed command mapping and completes the
command future exceptionally.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
`Json.convert` serializes already-parsed maps and lists through `JsonOutput` before coercion, imposing its 100-level `JsonOutput.MAX_DEPTH` on valid incoming BiDi results that were previously mapped directly from `JsonInput`.
## Fix Focus Areas
- java/src/org/openqa/selenium/json/Json.java[235-240]
- java/test/org/openqa/selenium/json/JsonTest.java[170-222]
## Recommended Fix
Replace the serialize-then-parse implementation with object-backed coercion that traverses parsed maps, lists, and scalar values directly, so received values never pass through `JsonOutput` or inherit its depth limit. Add a regression test that converts a parsed map or list nested beyond 100 levels (`JsonOutput.MAX_DEPTH`) and verifies that it reaches the requested target type without an output-depth failure.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Context sources
Review mode: 🚀 Fast: The push mainly adds localized BiDi unit tests and test-target configuration, with only documentation changes in runtime code and no new production logic.
Tip of the day
💡 Did you know, you can group findings by type and pick your Finding display, from Minimal to Full
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
B-atomsJavaScript chunks generated by Google closureB-buildIncludes scripting, bazel and CI integrationsB-devtoolsIncludes everything BiDi or Chrome DevTools relatedC-javaJava Bindings
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Related Issues
💥 What does this PR do?
The message received from browsers during a BiDi session was decoded 3 times or more for each incoming message. Fixing that to decode almost only once and use the decoded result to map to typed object.
🔧 Implementation Notes
Simplest way to do without interfering with other JSON flows.
🤖 AI assistance
💡 Additional Considerations
🔄 Types of changes