fix(interception): Return raw non-binary responses without metadata wrapper#14406
Merged
christian-bromann merged 7 commits intowebdriverio:mainfrom Apr 11, 2025
Merged
Conversation
added 5 commits
April 1, 2025 19:37
…nterception - Modified WebDriverInterception to correctly store and retrieve binary response data via getBinaryResponse() - Updated parseOverwrite to properly encode binary data in base64 format - Enhanced clear() to reset responseBodies map alongside calls array - Improved #handleResponseStarted to store binary response data - Added test case verifying binary response handling and clearing - Maintained compatibility with existing string/JSON response handling
…rapper - Updated WebDriverInterception.#handleResponseStarted to correctly unwrap non-binary responses before forwarding to networkProvideResponse, ensuring raw values are returned - Enhanced parseOverwrite to properly handle non-binary response bodies - Simplified convoluted getBinaryResponse with improved base64 validation - Added tests for non-binary responses and edge cases in getBinaryResponse
eslint-plugin-wdio
@wdio/allure-reporter
@wdio/appium-service
@wdio/browser-runner
@wdio/browserstack-service
@wdio/cli
@wdio/concise-reporter
@wdio/cucumber-framework
@wdio/config
@wdio/dot-reporter
@wdio/firefox-profile-service
@wdio/globals
@wdio/jasmine-framework
@wdio/json-reporter
@wdio/junit-reporter
@wdio/lighthouse-service
@wdio/local-runner
@wdio/logger
@wdio/mocha-framework
@wdio/protocols
@wdio/repl
@wdio/reporter
@wdio/runner
@wdio/sauce-service
@wdio/shared-store-service
@wdio/smoke-test-cjs-service
@wdio/smoke-test-reporter
@wdio/smoke-test-service
@wdio/spec-reporter
@wdio/static-server-service
@wdio/sumologic-reporter
@wdio/testingbot-service
@wdio/types
@wdio/utils
@wdio/webdriver-mock-service
webdriver
webdriverio
commit: |
Member
christian-bromann
left a comment
There was a problem hiding this comment.
One comment, otherwise LGTM
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Proposed changes
This pull request fixes a regression where non-binary mock responses were returned wrapped in
{ type: "string", value: "<mocked value>" }instead of the raw value specified (e.g.,{"data":{"someProperty":123}}). This issue, reported in #14390, was introduced by #14360, which modified response handling to support binary data but inadvertently affected non-binary mocksTypes of changes
Checklist
Backport Request
v9and doesn't need to be back-ported#XXXXXFurther comments
Why this solution?
{ type, value }structures to support binary data. Unwrapping non-binary responses in#handleResponseStartedrestores the expected behavior without altering binary supportgetBinaryResponsewith base64 validation (using a regex to detect invalid data) improves robustness for edge cases while keeping the method focused on binary dataparseOverwriteensures non-binary bodies are processed correctly without redundant encoding, maintaining compatibility with the WebDriver Bidi protocolAlternatives considered:
respondto avoid wrapping non-binary payloads at creation, but this risked breaking binary response storage logic. Unwrapping at the response stage (#handleResponseStarted) was safer and more targeted#responseBodiesfor non-binary data but kept it for consistency across response types, as it’s required forgetBinaryResponseReviewers: @webdriverio/project-committers