Skip to content

Actus 1.5.0

Choose a tag to compare

@github-actions github-actions released this 04 Sep 23:03
· 4 commits to main since this release

Fixed

  • A declared bool route-parameter default was unreachable. Every typed
    parameter reaches its default through the generated
    get_x(name).unwrap_or(default), which works because get_x returns Err
    on a missing parameter. bool is the one type whose absence is itself a
    usable value, so get_bool answered Ok(false) rather than erroring —
    unwrap_or unwrapped that false and the default was dead code. Every
    param: bool = true silently behaved as false. Found in a consumer: a
    cancellation route declaring at_period_end: bool = true cancelled
    immediately when the client omitted the parameter — the destructive
    direction, and the opposite of what the route documented. It stayed invisible
    because the route behaved correctly whenever the parameter was supplied.

    A bare param: bool is unchanged — it is required, and a request
    omitting it gets a 400, exactly as a bare String or u64 does. (An
    earlier draft of this entry said a bare bool reads false when absent.
    That was wrong and unverified: routing::resolve rejects it before
    extraction. An optional flag is spelled confirm: bool = false.)

  • ExtractedParams::get_bool now returns 400 when the parameter is absent,
    as get_string, get_i64 and every other scalar getter already did. It was
    the one getter that invented a value — Ok(false) — instead of erroring, and
    that invented value is what made a declared bool default unreachable.

    Not a breaking change, despite being a behaviour change to a public
    method: ExtractedParams has private fields and no public constructor, so
    routing::resolve is the only way to obtain one, and it rejects an absent
    bare bool before this method can be reached. The branch was unreachable from
    outside the crate. Use get_bool_optional to tell absence from an explicit
    false.

Added

  • ExtractedParams::get_bool_optional — distinguishes an absent bool
    parameter (None) from one supplied as false, which is the reader a
    declared default needs. Mirrors Params::get_bool_optional on the
    pre-resolution type.

  • routing::param_is_required(&ParamDef), re-exported at
    actus::routing: whether an absent value for a parameter makes the request a
    400the rule routing::resolve enforces, exported so a tool reporting
    requiredness cannot disagree with the router. The OpenAPI generator's
    required flag now calls it instead of re-deriving the same expression in a
    second crate, where the two agreed only by diligence and would have diverged
    the first time a new inherently-optional type was added.

    The rule it fixes in one place: a query parameter is required unless it
    declared a default
    , uniformly across every scalar type, so requiredness is
    readable off a routes! block without knowing the type. ParamType::StringArray
    is the sole exemption, and a forced one — urlencoding cannot express "present
    but empty", so no distinction is available to lose. bool is deliberately not
    exempt: exempting it would leave no way to declare a required bool, and would
    discard a distinction the wire does carry.