Invalid argument: cannot parse capability: goog:chromeOptions from invalid argument: cannot parse androidDeviceSerial from invalid argument: cannot be empty

Appium throws an error when chromeOptions are added to Appium Capabilities during Test runs or even when using Appium Inspector.

The error seems to be triggered by an Empty “androidDeviceSerial” capability within chromeOptions but it’s strange because I actually parse the cap’s value in my capabilities.
It seems that despite parsing the capability, Appium Ignores it and still throws an error.
Any Idea on how to solve this issue?

Chrome driver is auto installed because I run appium this way:
appium --base-path /wd/hub --allow-cors --session-override --allow-insecure chromedriver_autodownload

Error:

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: An unknown server-side error occurred while processing the command. Original error: invalid argument: cannot parse capability: goog:chromeOptions
from invalid argument: cannot parse androidDeviceSerial
from invalid argument: cannot be empty

Drivers:
Appium v2.4.1
[email protected]
java-client 9.2.0
selenium-java 4.17.0

Here are my Appium caps:

{
  "appium:deviceName": "Pixel_7",
  "appium:udid": "emulator-5554",
  "appium:platformName": "Android",
  "appium:platformVersion": "14",
  "browserName": "Chrome",
  "appium:appWaitActivity": "*",
  "appium:automationName": "uiautomator2",
  "appium:skipServerInstallation": false,
  "appium:noReset": true,
  "appium:disableIdLocatorAutocompletion": true,
  "appium:chromeOptions": {
    "androidPackage": "com.android.chrome",
    "androidDeviceSerial": "emulator-5554",
    "androidProcess": "com.android.chrome",
    "androidUseRunningApp": true,
    "args": [],
    "extensions": [],
    "w3c": false
  }
}

Here are the Caps returned by Appium with androidDeviceSerial somehow still Blank:

[Chromedriver@a651] ChromeDriver version: '113.0.5672.63'
[Chromedriver@a651] Matched '/status' to command name 'getStatus'
[Chromedriver@a651] Proxying [GET /status] to [GET http://127.0.0.1:60163/status] with no body
[Chromedriver@a651] connect ECONNREFUSED 127.0.0.1:60163
[Chromedriver@a651] Matched '/status' to command name 'getStatus'
[Chromedriver@a651] Proxying [GET /status] to [GET http://127.0.0.1:60163/status] with no body
[Chromedriver@a651] Got response with status 200: {"value":{"build":{"version":"113.0.5672.63 (0e1a4471d5ae5bf128b1bd8f4d627c8cbd55f70c-refs/branch-heads/5672@{#912})"},"message":"ChromeDriver ready for new sessions.","os":{"arch":"x86_64","name":"Windows NT","version":"10.0.22631"},"ready":true}}
[Chromedriver@a651] Starting W3C Chromedriver session with capabilities: {
[Chromedriver@a651]   "capabilities": {
[Chromedriver@a651]     "alwaysMatch": {
[Chromedriver@a651]       "goog:chromeOptions": {
[Chromedriver@a651]         "androidPackage": "com.android.chrome",
[Chromedriver@a651]         "androidDeviceSerial": "",
[Chromedriver@a651]         "androidProcess": "com.android.chrome",
[Chromedriver@a651]         "androidUseRunningApp": true,
[Chromedriver@a651]         "args": [],
[Chromedriver@a651]         "extensions": [],
[Chromedriver@a651]         "w3c": true
[Chromedriver@a651]       },
[Chromedriver@a651]       "goog:loggingPrefs": {
[Chromedriver@a651]         "browser": "ALL"
[Chromedriver@a651]       }
[Chromedriver@a651]     }
[Chromedriver@a651]   }
[Chromedriver@a651] }
[Chromedriver@a651] Matched '/session' to command name 'createSession'
[Chromedriver@a651] Proxying [POST /session] to [POST http://127.0.0.1:60163/session] with body: {"capabilities":{"alwaysMatch":{"goog:chromeOptions":{"androidPackage":"com.android.chrome","androidDeviceSerial":"","androidProcess":"com.android.chrome","androidUseRunningApp":true,"args":[],"extensions":[],"w3c":true},"goog:loggingPrefs":{"browser":"ALL"}}}}
[Chromedriver@a651] Got response with status 400: {"value":{"error":"invalid argument","message":"invalid argument: cannot parse capability: goog:chromeOptions\nfrom invalid argument: cannot parse androidDeviceSerial\nfrom invalid argument: cannot be empty","stacktrace":"Backtrace:\n\tGetHandleVerifier [0x00698893+48451]\n\t(No symbol) [0x0062B8A1]\n\t(No symbol) [0x00535058]\n\t(No symbol) [0x0054A94A]\n\t(No symbol) [0x0054F08E]\n\t(No symbol) [0x0054CD14]\n\t(No symbol) [0x0054F8D0]\n\t(No symbol) [0x0054A4DB]\n\t(No symbol) [0x0057F831]\n\t(No symbol) [0x0057F4E8]\n\t(No symbol) [0x00580620]\n\t(No symbol) [0x0058047C]\n\t(No symbol) [0x0057A0B6]\n\t(No symbol) [0x00557E08]\n\t(No symbol) [0x00558F2D]\n\tGetHandleVerifier [0x008F8E3A+2540266]\n\tGetHandleVerifier [0x00938959+2801161]\n\tGetHandleVerifier [0x0093295C+2776588]\n\tGetHandleVerifier [0x00722280+612144]\n\t(No symbol) [0x00634F6C]\n\t(No symbol) [0x006311D8]\n\t(No symbol) [0x006312BB]\n\t(No symbol) [0x00624857]\n\tBaseThreadInitThunk [0x75DB7BA9+25]\n\tRtlInitializeExceptionChain [0x775D...
[W3C] Matched W3C error code 'invalid argument' to InvalidArgumentError
[Chromedriver@a651] InvalidArgumentError: invalid argument: cannot parse capability: goog:chromeOptions
[Chromedriver@a651] from invalid argument: cannot parse androidDeviceSerial
[Chromedriver@a651] from invalid argument: cannot be empty
[Chromedriver@a651]     at errorFromW3CJsonCode (C:\Users\Derri\.appium\node_modules\appium-uiautomator2-driver\node_modules\@appium\base-driver\lib\protocol\errors.js:1085:25)
[Chromedriver@a651]     at ProxyRequestError.getActualError (C:\Users\Derri\.appium\node_modules\appium-uiautomator2-driver\node_modules\@appium\base-driver\lib\protocol\errors.js:954:14)

Full log:
appium androidSerial Error logs.txt (3.3 KB)