Automattic / Automattic/wordpress-rs

`WpNetworkResponse.init` uses `preconditionFailure` where the throwing error path already exists

Open Beginner friendly
#1,515 0 comments 0 reactions 0 assignees View on GitHub
Bug Error Handling Swift
Dominant language
Rust
Stars
36
Forks
5
Avg merge
17h 30m
Merged PRs (30d)
43

Description

> Split out from Automattic/wordpress-rs#1497 — *Swift executor URLSession error audit*. Section D — Crash instead of classified error.
>
> File references are to `native/swift/Sources/wordpress-api/SafeRequestExecutor.swift` unless noted; `:NNN` line numbers were verified against `fix/converge-executor-error-classification`.

**Severity: low.** `guard let response = response as? HTTPURLResponse else { preconditionFailure(...) }` (`Extensions.swift:17`). The initializer is already `throws` and is called inside `perform()`'s do-block, so `throw URLError(.badServerResponse)` degrades gracefully to `.genericError` today. Verified effectively unreachable for http(s) loads on Darwin and Linux — defense-in-depth, retained because the fix is one line. (The same verification cleared the completion-handler `data!`/`response!` force-unwraps on both platforms: no finding there.)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in native/swift/Sources/wordpress-api/SafeRequestExecutor.swift and inspect the WpNetworkResponse initializer, especially the guard at Extensions.swift:17 and its throwing call path from perform(). Done means the invalid response path no longer terminates the process and is reported through the existing classified error flow.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
networking
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.