Kotlin executor: OkHttp URL errors escape as internal errors

Open Beginner friendly
#1,758 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
kotlin, rust

Research direction

Read WpRequestExecutor.kt around line 95 and the executeRequestSafely error handling. Move request construction into the try and map IllegalArgumentException to RequestExecutionFailed; compare the Swift executor’s .badURL mapping for context. Verify that rejected URLs return a typed error instead of causing a panic through UniFFI.

Written by the indexing model from the issue text.

Description

Bug Error Handling Kotlin

On Android, a request address OkHttp rejects likely surfaces as an internal error instead of a typed RequestExecutionError.

What happens

WpRequestExecutor.kt:95 builds the OkHttp request with Request.Builder().url(...) outside executeRequestSafely's try/catch. OkHttp throws IllegalArgumentException for some addresses. In uniffi_core 0.32.2, an unexpected exception from a callback becomes a Rust panic, because RequestExecutionError has no From<UnexpectedUniFFICallbackError>.

Who is affected

Login with a typed host:port and no scheme, such as localhost:8080 or example.com:8080. The url crate reads the host as the scheme, and OkHttp rejects the result. An empty or relative XML-RPC RSD link would too (#1757), if that discovery is ever exported.

How this was checked

Found while testing #1746.

  • Confirmed: OkHttp 5.4.0's Request.Builder().url() throws IllegalArgumentException for example.invalid:0, an empty string, and relative addresses. It accepts {cdn} hosts.
  • Not run: the full chain through the Kotlin executor and UniFFI. The panic is read from the uniffi_core source.

Suggested fix

Build the OkHttp Request inside the try, and map IllegalArgumentException to a RequestExecutionFailed. The Swift executor maps .badURL to NonExistentSiteError.

Dominant language
Rust
Stars
38
Forks
6
Avg merge
2d 3h
Merged PRs (30d)
50

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Automattic/wordpress-rs

All issues in Automattic/wordpress-rs

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.