[🚀 Feature]: Remove deprecated JSON Wire ErrorCodes / Response.status (java)
Description
ErrorCodes and Response.status/getStatus()/setStatus() are leftover JSON Wire Protocol plumbing. They're still load-bearing in the W3C path: ErrorHandler resolves exceptions via getExceptionType(int) keyed off the integer Response.getStatus(). Removal is two independent efforts.
Interim state landed separately: both are now plain
@Deprecatedwith javadoc pointing at the replacement (noforRemoval, to avoid promising a removal that isn't scheduled and to keep the build warning-free until the migration below happens).
Track A — Response.status integer (internal only)
No external consumer found; doable entirely within this repo.
- [ ] Re-point
ErrorHandler(lines 102-104, 258) offgetExceptionType(int)onto the W3Cstatestring viaErrorCodec.decode(). - [ ] Migrate remaining internal readers of
getStatus()/setStatus():Response.fromJson,AbstractHttpResponseCodec,W3CHttpResponseCodec,W3CHandshakeResponse,ProtocolHandshake,ResponseConverter. - [ ] Flip
Response.status/getStatus()/setStatus()to@Deprecated(forRemoval = true)once the internal callers above are gone (no consumers left to warn). - [ ] Remove
Response.status/getStatus()/setStatus().
Track B — ErrorCodes (public API, Appium depends on it)
Appium subclasses it (ErrorCodesMobile extends ErrorCodes) and injects via new ErrorHandler(new ErrorCodesMobile(), true). Requires cross-repo sequencing:
- [ ] (Selenium) Make
ErrorCodecextensible — public API to register customstate → exceptionmappings (currently private ctor + private staticERRORSlist). - [ ] (Selenium) Add an
ErrorHandlerconstructor takingErrorCodec; oldErrorHandler(ErrorCodes, …)delegates and stays deprecated. - [ ] (Appium) Replace the subclass with one registration:
"No such context found" → NoSuchContextException. (then wait for an Appium release) - [ ] (Selenium) Mark
ErrorCodes+ErrorHandler(ErrorCodes, …)forRemoval, then remove in a major release.
Have you considered any alternatives or workarounds?
Keep ErrorCodes indefinitely as legacy API and never remove it — needs no Appium coordination, reclaims no code.
Does this apply to specific language bindings?
Java
@titusfortner, thank you for creating this issue. We will troubleshoot it as soon as we can.
Selenium Triage Team: remember to follow the Triage Guide
Hi @titusfortner, is Track A available to pick up? Happy to take it if nobody's on it.
My reading of the scope, to check I've understood it correctly:
- Re-point
ErrorHandleroffgetExceptionType(int)onto the W3Cstatestring viaErrorCodec.decode()(lines ~102-104 and 258). - Migrate the remaining internal readers of
getStatus()/setStatus():Response.fromJson,AbstractHttpResponseCodec,W3CHttpResponseCodec,W3CHandshakeResponse,ProtocolHandshake,ResponseConverter. - Flip
Response.status/getStatus()/setStatus()to@Deprecated(forRemoval = true)once those callers are gone. - Remove them.
Two questions before I start:
- Would you prefer this as one PR or split — say, the
ErrorHandlerre-point and internal migration first, then the removal separately once that's had a release cycle to settle? - Is there a preferred fallback when
ErrorCodec.decode()can't resolve astatestring, or should that surface as it does today?
I'd leave Track B alone given the Appium sequencing.
I've also got #18025 open (small UploadHandler fix for #18010), so I'm familiar with the build and test setup.
@yashp676 no one is working on it that I know of. It'd take me too long to dig back through things to figure out the context. PR what you think seems right and we'll take a look. Feel free to reach out on Slack if you want to discuss more - https://inviter.co/seleniumhq
Thanks — I'll take Track A and leave Track B alone given the Appium sequencing.
Planning to split it: first PR re-points ErrorHandler onto ErrorCodec.decode() and migrates the internal getStatus() readers, second handles the forRemoval flip and removal once that's settled. Shout if you'd rather see it as one.
Opened #18059 for the first Track A item.
ErrorHandler now resolves exception types from the W3C state rather than the JSON Wire integer, so it no longer reads Response.getStatus(). Went via ErrorCodes.getExceptionType(String) rather than ErrorCodec.decode() — reasoning in the PR description, happy to redo it if you'd rather.
One thing worth flagging: the (String, Throwable, Integer) branch in createThrowable was dead. No exception under java/src/org/openqa/selenium/ declares that constructor, so it always fell through. Removed in the same PR.
ResponseConverter is on the list above but looks out of scope — its getStatus() calls are HttpResponse's HTTP status, not Response.status.
Next up is the remaining internal getStatus() readers, once this one's had a look.
Hi @titusfortner and @diemol
Track A update:
- #18059 (merged):
ErrorHandlerresolves exceptions from the W3C state. - #18171: migrates the remaining internal
getStatus()/setStatus()callers, so nothing injava/srctouches the integer status any more. - #18172 (draft): marks
Response.statusfor removal, then removes it, as two separate commits. It's a draft because it's stacked on #18171 — the removal only compiles once those callers are gone, and until #18171 merges its diff also includes that commit. I'll rebase and mark it ready once #18171 lands.
Separately, on Track B: Appium java-client 11.0.0 (appium/java-client#2462) no longer depends on selenium-remote-driver and ships its own ErrorCodes/ErrorHandler/Response. Would it be worth revisiting whether Track B still needs the extensible ErrorCodec step?