Skip to content

Remove two unreachable error arms in peryx #2196

Description

@gaborbernat

Problem

Two error arms in peryx handle states their callers rule out. Both are map_err closures, so each is an uncallable function rather than only an unreached line.

crates/peryx/src/app/retention.rs:117

let header = serde_json::to_string(&serde_json::json!({ "summary": summary })).map_err(|error| error.to_string())?;

json! produces a serde_json::Value, whose Serialize impl has no error path, and the sink is an in-memory String. to_string on a Value cannot return Err, so the closure never runs.

crates/peryx/src/server.rs:781

let allowed_events = plugins
    .webhook_events(&index.ecosystem)
    .map_err(anyhow::Error::msg)

webhook_events fails only through registration(ecosystem)?, which errors for an ecosystem that is not installed. Both callers of build_webhooks resolve every configured ecosystem first:

  • check_config_with_active_plugins runs build_indexes_with_plugins at line 125, which calls plugins.activate(...) and returns MissingEcosystem before build_webhooks at line 127.
  • build_state_with_active_backend_and_plugins runs build_index_settings_with_plugins at line 228, which calls compile_index_settings for every config, and that delegates to the same registration(ecosystem)? at plugin-registry/src/lib.rs:576. build_webhooks follows at line 229.

The second guard is strictly the wider one: build_index_settings_with_plugins iterates all configs, while build_webhooks looks only at those carrying webhooks.

Why it matters now

The native coverage gate holds main to 100% of measurable lines (#2162, #1745). A line no input can reach is neither coverable by a test nor removable by one, so each of these blocks that gate exactly as #2180 and #2190 did. These are the third and fourth instances of the class found while closing #2166.

Required change

Remove both map_err closures and let the infallible call stand on its own. Where a message is still wanted for a Result the compiler requires, use expect with the reason, matching how the surrounding code states invariants it does not check.

Acceptance criteria

  • Neither line appears in the crate's missed-line list.
  • cargo llvm-cov for peryx reports two fewer functions, since removing the closures removes uncallable functions rather than only unreached lines.
  • The registration failures those guards produce keep their existing coverage and messages.
  • No behaviour change: no input reached either arm before.

Boundary

Only these two closures. The writeln! map_err on the following line of retention.rs, the with_context on build_webhooks, and every other map_err in both files stay — they are reachable.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:P2Performance, observability, or deferred featuretype:bugIncorrect behavior or missing validation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions