Skip to content

[rust-LIN-12] Structural conversion failures collapse to the Closed sentinel instead of an invalid-frame condition #38

Description

@SoundMatt

Location

src/relay.rsrelay::Error (4 variants: Closed, NotConnected, Timeout, PayloadTooLarge); src/error.rs — the crate-level Error enum and its kind() method; src/adapt.rs — the two call sites that do .kind().unwrap_or(crate::relay::Error::Closed).

Problem

The crate maintains two separate error enums: the small relay::Error (the RELAY-sentinel-shaped one, 4 variants) and a richer crate-level Error with additional LIN-specific variants including InvalidFrame. Error::kind() maps most of the crate-level variants back onto a relay::Error sentinel, but InvalidFrame isn't mapped to anything — it falls through to None. In the adapter, when a structural conversion failure occurs (a bad frame ID or wrong protocol produces an InvalidFrame), the code does .kind().unwrap_or(crate::relay::Error::Closed), so that None gets converted to Closed. A caller then sees an error that looks like "the bus is closed" for what was actually a bad-ID or malformed-input failure — a misleading sentinel, since Closed specifically implies a closed bus/subscription, not a structural validation failure.

Suggested fix

Map structural failures to a distinct relay::Error condition (an invalid-frame-shaped sentinel) rather than falling back to Closed, so callers doing sentinel-based error handling get an accurate signal instead of a misleading "bus closed" result.


Filed from the 2026-07-29 ecosystem audit register; independently re-verified against current HEAD before filing.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions